pycharm制作柱状图

news2024/10/6 20:25:57

 Bar - Bar_rotate_xaxis_label

解决标签名字过长的问题

from pyecharts import options as opts
from pyecharts.charts import Bar

c = (
    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 Faker

c = (
    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.coloradmin.cn/o/819759.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

MBA拓展有感-见好就收,还是挑战到底?MBA拓展有感-见好就收,还是挑战到底?

今天看到新闻提到某位坚持了14年高考的同学滑档&#xff0c;让人心生感叹&#xff1a;无论在日常工作还是生活中&#xff0c;选择都是非常重要的。不由想起前段时间我参加研究生新生拓展时的一些感悟&#xff0c;和大家分享一下。 事情的起因是拓展活动中的一个分队竞技类的活…

利用DIE、de4dot和dnspy进行反编译

1.数据准备 1.软件 知云翻译7.0这个版本好破解&#xff0c;该软件是C#写的程序 DIE&#xff08;Detect it Easy&#xff09;该软件是进行查看软件的壳及编译程序&#xff0c;详细了解EXE软件 de4dot是对PE进行脱壳处理&#xff0c;源码下载链接&#xff1a;GitHub - de4dot…

JAVA开发工具-maven的安装与配置(最新最详细教程)

引言 Maven项目对象模型(POM)&#xff0c;可以通过一小段描述信息来管理项目的构建&#xff0c;报告和文档的项目管理工具 软件。 Maven 除了以程序构建能力为特色之外&#xff0c;还提供高级项目管理工具。由于 Maven 的缺省构建规则有较 高的可重用性&#xff0c;所以常常用两…

lc1074.元素和为目标值的子矩阵数量

创建二维前缀和数组 两个for循环&#xff0c;外循环表示子矩阵的左上角&#xff08;x1,y1&#xff09;&#xff0c;内循环表示子矩阵的右下角&#xff08;x2,y2&#xff09; 两个for循环遍历&#xff0c;计算子矩阵的元素总和 四个变量&#xff0c;暴力破解的时间复杂度为O(…

点云处理——terrasolid教程

加载terrasolid软件模块 3、通过microstation的utilities->mdl applications加载terrasolid四个模块,加载成功后将显示tscan和tphoto的主窗口&#xff0c;以及四个模块的主工具箱。 浏览点云 4、显示点云坐标信息(类&#xff0c; 航带号&#xff0c;GPS信息&#xff0c;东…

小夜灯的体势红外传感器 > 红外知识学习

红外是电磁辐射谱中的一部分&#xff0c;它位于可见光谱的红色边缘之外&#xff0c;具有较长的波长。可见光谱是人眼能够感知的电磁辐射范围&#xff0c;而红外光的波长较长&#xff0c;人眼无法感知。 生命光的范围是6~14um 红外光的波长范围一般约为0.7um~1000um&#xff08;…

多模块Springboot项目maven单独打包子模块

背景介绍 最近接手一个项目代号XXL&#xff0c;是一个多模块的Springboot项目&#xff0c;在解决了线上的bug之后&#xff0c;想单独给子模块打包上线部署&#xff0c;问题来了。如果整个工程一起mvn -X -DskipTests clean package&#xff0c;打包出来的XXL-web.jar是可以正常…

打通数据治理全链路,火山引擎DataLeap数据治理平台公有云版本正式发布

更多技术交流、求职机会&#xff0c;欢迎关注字节跳动数据平台微信公众号&#xff0c;回复【1】进入官方交流群 近日&#xff0c;火山引擎DataLeap正式对外发布数据治理平台公有云版。DataLeap是火山引擎大数据研发治理套件&#xff0c;随着其子套件数据治理平台与CDH引擎底座成…

等待已久,新品上市 | RevPi Connect 4系列:基于树莓派CM4计算模块的全新工业树莓派

新品来袭 势不可挡 备受期待的虹科工业树莓派第四代产品—RevPi Connect 4终于来啦&#xff01;作为全球领先的工业自动化产品&#xff0c;RevPi Connect 4融合了工业树莓派多年技术积累与创新突破&#xff0c;以及现代物联网技术的结晶。无论您是行业领先者、工程师还是智能科…

tinkerCAD案例:29. 摇头娃娃

Research Your Favorite Bobblehead 摇头娃娃 Project Overview: 项目概况&#xff1a; Design and create your favorite Minecraft 3D bobble head. All you need is a computer, 3D printer, spring and your creativity to your favorite Minecraft character in the for…

远程访问本地mysql

文章目录 一、设置本地mysql允许外部访问找到mysql配置文件my.ini &#xff0c;linux环境是my.cnf配置mysql配置文件 二、创建外部访问的mysql用户三、配置mysql用户的权限四、配置防火墙端口五、连接查看本地ip地址 参考 连接命令 mysql -h <host> -P <port> -u &…

Hive/Spark/Yarn: User Not Found 错误和 Kerberos / AD / OpenLDAP 之间的关系与解释

有时候,当你向Spark或Hive提交作业时,可能会遇到如下的错误: 提交作业使用的用户是example-user-1,但是Yarn返回的错误信息是:该用户不存在。类似的问题大多发生在启动了Kerberos的Hadoop集群上,或者集群集成了Windows AD或OpenLDAP后。本文,我们把这个问题梳理清楚并给…

【MySQL】触发器 (十二)

🚗MySQL学习第十二站~ 🚩本文已收录至专栏:MySQL通关路 ❤️文末附全文思维导图,感谢各位点赞收藏支持~ 一.引入 触发器是与表有关的数据库对象,作用在insert/update/delete语句执行之前(BEFORE)或之后(AFTER),自动触发并执行触发器中定义的SQL语句集合。它可以协助应…

从SQL注入绕过最新安全狗WAF中学习fuzz

前言 SQL注入并不是很精通&#xff0c;通过实战绕过WAF来进行加强SQL注入能力&#xff0c;希望对正在学习的师傅能有一丝帮助。 安装 安装前言 我是本地搭建的环境进行测试的 环境是windows11phpstudy2018sqli-labs phpstudy的安装我不再复述&#xff0c;这里简单说一下安全…

java 企业工程管理系统软件源码 自主研发,工程行业适用

&#xfeff; 工程项目管理软件&#xff08;工程项目管理系统&#xff09;对建设工程项目管理组织建设、项目策划决策、规划设计、施工建设到竣工交付、总结评估、运维运营&#xff0c;全过程、全方位的对项目进行综合管理 工程项目各模块及其功能点清单 一、系统管理 1、数据…

Acwing.874 筛法求欧拉函数

题目 给定一个正整数n&#xff0c;求1~n中每个数的欧拉函数之和。 输入格式 共—行&#xff0c;包含一个整数n。 输出格式 共一行&#xff0c;包含一个整数&#xff0c;表示1~n中每个数的欧拉函数之和。 数据范围 1 ≤n ≤106 输入样例: 6输出样例: 12题解 #include…

React(4)

1.属性&#xff08;props&#xff09;初始 状态state都是组件内部写的&#xff0c;也就是A组件内的state就只能A组件里面用&#xff0c;其他组件复用不了。因此属性props就可以。 比如一个导航栏&#xff0c;首页有&#xff0c;购物车有&#xff0c;我的有&#xff0c;他们三个…

DNS泄漏:你的个人信息是否正被公开?

在今天的互联网世界中&#xff0c;数量庞大的个人信息被储存在各种网络平台和服务器上&#xff0c;其中包括我们的姓名、地址、电话号码、电子邮件地址等等。这些信息对我们的生活至关重要&#xff0c;但同时也会使我们面临着网络安全威胁&#xff0c;其中之一便是DNS泄漏。在本…

sdr- spectrum analyzer

0000000000000000675c62dc314764cf 433.92 M 315M

Day03-作业(AxiosElementUI)

作业1&#xff1a; 根据需求完成如下页面数据列表展示 需求&#xff1a;Vue挂载完成后,通过axios发送异步请求到服务端,获取学生列表数据,并通过Vue展示在页面上 获取数据url&#xff1a;http://yapi.smart-xwork.cn/mock/169327/student 素材&#xff1a; <!DOCTYPE html…