当前位置: 首页 > news >正文

pycharm制作柱状图

 Bar - Bar_rotate_xaxis_label

解决标签名字过长的问题

from pyecharts import options as opts
from pyecharts.charts import Barc = (Bar().add_xaxis(["高等数学1,2","C语言程序设计","python程序设计","大数据导论","数据结构","大数据与人工智能",]).add_yaxis("大一的学习效率", [10, 20, 30, 40, 50, 40]).add_yaxis("大二的学习效率", [20, 10, 40, 30, 40, 50]).set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),   #此行代码旋转标签的角度title_opts=opts.TitleOpts(title="信阳农林学院信息工程学院", subtitle="数据科学与大数据技术21-2"),).render("bar_rotate_xaxis_label.html")
)
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>Awesome-pyecharts</title><script type="text/javascript" src="https://assets.pyecharts.org/assets/v5/echarts.min.js"></script></head>
<body ><div id="8601599b79914f0cb28546e9b9a362e3" class="chart-container" style="width:900px; height:500px; "></div><script>var chart_8601599b79914f0cb28546e9b9a362e3 = echarts.init(document.getElementById('8601599b79914f0cb28546e9b9a362e3'), 'white', {renderer: 'canvas'});var option_8601599b79914f0cb28546e9b9a362e3 = {"animation": true,"animationThreshold": 2000,"animationDuration": 1000,"animationEasing": "cubicOut","animationDelay": 0,"animationDurationUpdate": 300,"animationEasingUpdate": "cubicOut","animationDelayUpdate": 0,"aria": {"enabled": false},"color": ["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],"series": [{"type": "bar","name": "\u5927\u4e00\u7684\u5b66\u4e60\u6548\u7387","legendHoverLink": true,"data": [10,20,30,40,50,40],"realtimeSort": false,"showBackground": false,"stackStrategy": "samesign","cursor": "pointer","barMinHeight": 0,"barCategoryGap": "20%","barGap": "30%","large": false,"largeThreshold": 400,"seriesLayoutBy": "column","datasetIndex": 0,"clip": true,"zlevel": 0,"z": 2,"label": {"show": true,"margin": 8}},{"type": "bar","name": "\u5927\u4e8c\u7684\u5b66\u4e60\u6548\u7387","legendHoverLink": true,"data": [20,10,40,30,40,50],"realtimeSort": false,"showBackground": false,"stackStrategy": "samesign","cursor": "pointer","barMinHeight": 0,"barCategoryGap": "20%","barGap": "30%","large": false,"largeThreshold": 400,"seriesLayoutBy": "column","datasetIndex": 0,"clip": true,"zlevel": 0,"z": 2,"label": {"show": true,"margin": 8}}],"legend": [{"data": ["\u5927\u4e00\u7684\u5b66\u4e60\u6548\u7387","\u5927\u4e8c\u7684\u5b66\u4e60\u6548\u7387"],"selected": {},"show": true,"padding": 5,"itemGap": 10,"itemWidth": 25,"itemHeight": 14,"backgroundColor": "transparent","borderColor": "#ccc","borderWidth": 1,"borderRadius": 0,"pageButtonItemGap": 5,"pageButtonPosition": "end","pageFormatter": "{current}/{total}","pageIconColor": "#2f4554","pageIconInactiveColor": "#aaa","pageIconSize": 15,"animationDurationUpdate": 800,"selector": false,"selectorPosition": "auto","selectorItemGap": 7,"selectorButtonGap": 10}],"tooltip": {"show": true,"trigger": "item","triggerOn": "mousemove|click","axisPointer": {"type": "line"},"showContent": true,"alwaysShowContent": false,"showDelay": 0,"hideDelay": 100,"enterable": false,"confine": false,"appendToBody": false,"transitionDuration": 0.4,"textStyle": {"fontSize": 14},"borderWidth": 0,"padding": 5,"order": "seriesAsc"},"xAxis": [{"show": true,"scale": false,"nameLocation": "end","nameGap": 15,"gridIndex": 0,"axisLabel": {"show": true,"rotate": -15,"margin": 8},"inverse": false,"offset": 0,"splitNumber": 5,"minInterval": 0,"splitLine": {"show": true,"lineStyle": {"show": true,"width": 1,"opacity": 1,"curveness": 0,"type": "solid"}},"data": ["\u9ad8\u7b49\u6570\u5b661\uff0c2","C\u8bed\u8a00\u7a0b\u5e8f\u8bbe\u8ba1","python\u7a0b\u5e8f\u8bbe\u8ba1","\u5927\u6570\u636e\u5bfc\u8bba","\u6570\u636e\u7ed3\u6784","\u5927\u6570\u636e\u4e0e\u4eba\u5de5\u667a\u80fd"]}],"yAxis": [{"show": true,"scale": false,"nameLocation": "end","nameGap": 15,"gridIndex": 0,"inverse": false,"offset": 0,"splitNumber": 5,"minInterval": 0,"splitLine": {"show": true,"lineStyle": {"show": true,"width": 1,"opacity": 1,"curveness": 0,"type": "solid"}}}],"title": [{"show": true,"text": "\u4fe1\u9633\u519c\u6797\u5b66\u9662\u4fe1\u606f\u5de5\u7a0b\u5b66\u9662","target": "blank","subtext": "\u6570\u636e\u79d1\u5b66\u4e0e\u5927\u6570\u636e\u6280\u672f21-2","subtarget": "blank","padding": 5,"itemGap": 10,"textAlign": "auto","textVerticalAlign": "auto","triggerEvent": false}]
};chart_8601599b79914f0cb28546e9b9a362e3.setOption(option_8601599b79914f0cb28546e9b9a362e3);</script>
</body>
</html>

 

 Bar - Bar_stack0

叠层柱状图

可以求比例

from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Fakerc = (Bar().add_xaxis(["高等数学1,2","C语言程序设计","python程序设计","大数据导论","数据结构","大数据与人工智能",]).add_yaxis("大一的学习效率", [10, 20, 30, 40, 50, 40],stack="stack1")  # stack="stack1" 表示同一列.add_yaxis("大二的学习效率", [20, 30, 50, 60, 70, 80],stack="stack1")  #.set_series_opts(label_opts=opts.LabelOpts(is_show=False)).set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),title_opts=opts.TitleOpts(title="信息工程学院学习知识所占百分比")).render("bar_stack0.html")
)
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>Awesome-pyecharts</title><script type="text/javascript" src="https://assets.pyecharts.org/assets/v5/echarts.min.js"></script></head>
<body ><div id="ef493756d92b45dcb840f2c58c5f385f" class="chart-container" style="width:900px; height:500px; "></div><script>var chart_ef493756d92b45dcb840f2c58c5f385f = echarts.init(document.getElementById('ef493756d92b45dcb840f2c58c5f385f'), 'white', {renderer: 'canvas'});var option_ef493756d92b45dcb840f2c58c5f385f = {"animation": true,"animationThreshold": 2000,"animationDuration": 1000,"animationEasing": "cubicOut","animationDelay": 0,"animationDurationUpdate": 300,"animationEasingUpdate": "cubicOut","animationDelayUpdate": 0,"aria": {"enabled": false},"color": ["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],"series": [{"type": "bar","name": "\u5927\u4e00\u7684\u5b66\u4e60\u6548\u7387","legendHoverLink": true,"data": [10,20,30,40,50,40],"realtimeSort": false,"showBackground": false,"stack": "stack1","stackStrategy": "samesign","cursor": "pointer","barMinHeight": 0,"barCategoryGap": "20%","barGap": "30%","large": false,"largeThreshold": 400,"seriesLayoutBy": "column","datasetIndex": 0,"clip": true,"zlevel": 0,"z": 2,"label": {"show": false,"margin": 8},"rippleEffect": {"show": true,"brushType": "stroke","scale": 2.5,"period": 4}},{"type": "bar","name": "\u5927\u4e8c\u7684\u5b66\u4e60\u6548\u7387","legendHoverLink": true,"data": [20,30,50,60,70,80],"realtimeSort": false,"showBackground": false,"stack": "stack1","stackStrategy": "samesign","cursor": "pointer","barMinHeight": 0,"barCategoryGap": "20%","barGap": "30%","large": false,"largeThreshold": 400,"seriesLayoutBy": "column","datasetIndex": 0,"clip": true,"zlevel": 0,"z": 2,"label": {"show": false,"margin": 8},"rippleEffect": {"show": true,"brushType": "stroke","scale": 2.5,"period": 4}}],"legend": [{"data": ["\u5927\u4e00\u7684\u5b66\u4e60\u6548\u7387","\u5927\u4e8c\u7684\u5b66\u4e60\u6548\u7387"],"selected": {},"show": true,"padding": 5,"itemGap": 10,"itemWidth": 25,"itemHeight": 14,"backgroundColor": "transparent","borderColor": "#ccc","borderWidth": 1,"borderRadius": 0,"pageButtonItemGap": 5,"pageButtonPosition": "end","pageFormatter": "{current}/{total}","pageIconColor": "#2f4554","pageIconInactiveColor": "#aaa","pageIconSize": 15,"animationDurationUpdate": 800,"selector": false,"selectorPosition": "auto","selectorItemGap": 7,"selectorButtonGap": 10}],"tooltip": {"show": true,"trigger": "item","triggerOn": "mousemove|click","axisPointer": {"type": "line"},"showContent": true,"alwaysShowContent": false,"showDelay": 0,"hideDelay": 100,"enterable": false,"confine": false,"appendToBody": false,"transitionDuration": 0.4,"textStyle": {"fontSize": 14},"borderWidth": 0,"padding": 5,"order": "seriesAsc"},"xAxis": [{"show": true,"scale": false,"nameLocation": "end","nameGap": 15,"gridIndex": 0,"axisLabel": {"show": true,"rotate": -15,"margin": 8},"inverse": false,"offset": 0,"splitNumber": 5,"minInterval": 0,"splitLine": {"show": true,"lineStyle": {"show": true,"width": 1,"opacity": 1,"curveness": 0,"type": "solid"}},"data": ["\u9ad8\u7b49\u6570\u5b661\uff0c2","C\u8bed\u8a00\u7a0b\u5e8f\u8bbe\u8ba1","python\u7a0b\u5e8f\u8bbe\u8ba1","\u5927\u6570\u636e\u5bfc\u8bba","\u6570\u636e\u7ed3\u6784","\u5927\u6570\u636e\u4e0e\u4eba\u5de5\u667a\u80fd"]}],"yAxis": [{"show": true,"scale": false,"nameLocation": "end","nameGap": 15,"gridIndex": 0,"inverse": false,"offset": 0,"splitNumber": 5,"minInterval": 0,"splitLine": {"show": true,"lineStyle": {"show": true,"width": 1,"opacity": 1,"curveness": 0,"type": "solid"}}}],"title": [{"show": true,"text": "\u4fe1\u606f\u5de5\u7a0b\u5b66\u9662\u5b66\u4e60\u77e5\u8bc6\u6240\u5360\u767e\u5206\u6bd4","target": "blank","subtarget": "blank","padding": 5,"itemGap": 10,"textAlign": "auto","textVerticalAlign": "auto","triggerEvent": false}]
};chart_ef493756d92b45dcb840f2c58c5f385f.setOption(option_ef493756d92b45dcb840f2c58c5f385f);</script>
</body>
</html>

 

http://www.lryc.cn/news/107117.html

相关文章:

  • 静态资源导入探究
  • 安全狗V3.512048版本绕过
  • prometheus监控k8s kube-proxy target down
  • SPSS数据分析--假设检验的两种原假设取舍决定方式
  • Python实现猫狗分类
  • pjsip、pjsua2+bcg729 windows下编译java版本
  • 尝试多数据表 sqlite
  • Keil出现Flash Timeout.Reset the Target and try it again.我有一种解决方法
  • 纯粹即刻,畅享音乐搜索的轻松体验
  • 动态规划之树形DP
  • 嵌入式_GD32使用宏开关进行Debug串口打印调试
  • 使用 GitHub Copilot 进行 Prompt Engineering 的初学者指南(译)
  • c++开发模式,享元模式
  • LLM大模型——langchain相关知识总结
  • 【Python】数据可视化利器PyCharts在测试工作中的应用
  • AOP的实战(统一功能处理模块)
  • 时间复杂度为O(n2)的三种简单排序算法
  • LeetCode 热题 100 JavaScript --226. 翻转二叉树
  • hive所有窗口函数详情总结
  • Talk | 新加坡国立大学博士生施宇钧:DragDiffusion-基于扩散模型的关键点拖拽图片编辑
  • 22 | 贝叶斯分类算法
  • java.sql.SQLSyntaxErrorException: ORA-00909: 参数个数无效
  • 数据结构8-哈希表
  • vue3引用Font-Awesome字体图标库
  • Python: Django 服务部署可能遇到的一些问题
  • Python爬虫时遇到连接超时解决方案
  • 这所国字头双一流,根本招不满,学硕都没人报!
  • macos 查询端口占用 命令
  • 无代码开发:打破传统开发模式,引领数字化转型新方向
  • go-zero超强工具goctl的常用命令api,rpc,model及其构建的服务解析