这篇文章主要介绍“如何用cutecharts库绘制手绘风格的可视化图形”,在日常操作中,相信很多人在如何用cutecharts库绘制手绘风格的可视化图形问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何用cutecharts库绘制手绘风格的可视化图形”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
高邑ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
# 导入相关的库 import cutecharts.charts as ctc import pandas as pd from cutecharts.components import Page # 构造数据 df = pd.DataFrame({ "x":["蔬菜", "水果", "水产", "猪肉", "零食", "电商", "物料"], "y":[100, 130, 169, 220, 286, 372, 484], "z":[20, 26, 34, 44, 57, 74, 96]})
1. 柱形图
chart = ctc.Bar("各品类的销售业绩", width = "500px", height = "400px") chart.set_options(labels = list(df["x"]), x_label ="部门", y_label= "销售额(万元)", colors = ["#1EAFAE" for i in range(len(df))] ) chart.add_series("2020年",list(df["y"])) chart.render_notebook()
1.1 自定义各根柱子的颜色
chart = ctc.Bar("各品类的销售业绩", width = "500px", height = "400px") chart.set_options(labels=list(df["x"]), x_label = "2020年", y_label = "销售额(万元)", colors = ["yellow","orange","pink","red","purple","green","blue"] ) chart.add_series("2020年",list(df["y"])) chart.render_notebook()
渲染效果:
2. 折线图
chart = ctc.Line("各品类的销售业绩",width = "500px", height = "400px") chart.set_options(labels = list(df["x"]), x_label ="2020年环比2019年", y_label = "销售额(万元)" ) chart.add_series("今年", list(df["y"])) chart.add_series("去年", list(df["z"])) chart.render_notebook()
3. 雷达图
chart = ctc.Radar("各品类的销售业绩",width = "700px", height = "600px") chart.set_options(labels=list(df["x"]), is_show_legend = True, #by default, it is true. You can turn it off. legend_pos = "upRight" #location of the legend ) chart.add_series("2020年",list(df["y"])) chart.add_series("2019年",list(df["z"])) chart.render_notebook()
4. 饼图
chart = ctc.Pie("各品类销售业绩占比",width ="500px",height = "400px") chart.set_options(labels=list(df["x"]),inner_radius=0) chart.add_series(list(df["y"])) chart.render_notebook()
5. 环形图
chart = ctc.Pie("各品类销售业绩占比",width ="500px",height = "400px") chart.set_options(labels=list(df["x"]),inner_radius=0.6) chart.add_series(list(df["y"])) chart.render_notebook()
6. 散点图
# 再构造一组数据 amount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] sales = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]
chart = ctc.Scatter("某种定价商品的销售额与销售量之间的关系",width= "500px",height = "600px") chart.set_options(x_label = "销售数量(件)", y_label = "销售额(元)", colors=["#1EAFAE"], is_show_line = False, dot_size = 1) chart.add_series("进口香印青提", [(z[0], z[1]) for z in zip(amount, sales)]) chart.render_notebook()
7. 组合图
chart1 = ctc.Line("各品类的销售业绩",width ="500px",height ="400px") chart1.set_options(labels=list(df["x"]), x_label = "品类",y_label = "销售额(万元)" ) chart1.add_series("2020年", list(df["y"])) chart1.add_series("2019年", list(df["z"])) chart2 = ctc.Bar("各品类的销售业绩",width = "500px",height = "400px") chart2.set_options(labels=list(df["x"]),x_label = "品类", y_label = "销售额(万元)" ,colors=["#1EAFAE" for i in range(len(df))]) chart2.add_series("2020年", list(df["y"])) chart2.add_series("2019年", list(df["z"])) page = Page() page.add(chart1, chart2) page.render_notebook()
到此,关于“如何用cutecharts库绘制手绘风格的可视化图形”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!
分享标题:如何用cutecharts库绘制手绘风格的可视化图形
分享URL:https://www.cdcxhl.com/article18/poejgp.html
成都网站建设公司_创新互联,为您提供电子商务、网站策划、软件开发、网站营销、企业网站制作、Google
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联