pyecharts

Posted pannizhe123900402

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pyecharts相关的知识,希望对你有一定的参考价值。

#网址:https://echarts.apache.org/examples/zh/index.html
#网址:https://www.cnblogs.com/hustcser/p/8831176.html 和 https://blog.csdn.net/u012535605/article/details/80677791
#版本:pip install pyecharts==0.5.5
#参数
# https://blog.csdn.net/weixin_43746433/article/details/97766914?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1

1、柱状图
form pyecharts import Bar

x=["电视","冰箱","洗衣机","空调"]

a=[123,234,123,256]

b=[231,125,236,339]
c=[243,236,222,123]

bar=Bar("各分公司销售数据",title_pos="40%",background_color="yellow")
#title_pos标题的位置,background_color背景颜色,title_color标题字体颜色

bar.use_theme("dark")#设置图表的主题
bar.add("苏宁",x,a,mark_point= ["max","min"],legend_top ="8%",is_label_show= True)#显示最大值和最小值,legend_top图列标题的位置,is_label_show显示数据标签

bar.add("京东",x,b,mark_point= ["max","min"],legend_top ="8%")#label_color=[‘yellow‘]柱的颜色

bar.add("小米",x,c,mark_point= ["max","min"],legend_top ="8%")#显示最大值和最小值,legend_top图列的位置

bar.render("D:My DocumentsDesktopshashs.html")
2、堆积图
bar=Bar ("堆积图",title_pos= "40%",width= 1200,height= 600)#title_pos标题名称的位置,width图表的长度,height图表的宽度
bar.add("苏宁",x,a,legend_top= "8%",mark_point= ["max","min"],is_stack= True )#is_stack=True是否是堆积

bar.add("京东",x,b,legend_top= "8%",mark_point= ["max","min"],is_stack= True )

bar.render("D:My DocumentsDesktopshashs.html")

3、
饼图
from  pyecharts import Pie

a=[1,2,3,4]

b=[5,6,7,8]

c=[2,3,4,5]

x=["张三","李四","王五","朱六"]

pie=Pie (‘饼图‘,title_pos ="50%",width= 1290,height= 1000)#background_color背景颜色,title_color标题字体颜色

pie.use_theme("roma")

pie.add(‘商品A‘,x,a,radius= [30,60],rosetype="area", center=[20,40],is_label_show= True)#radius= [30,75]表示是一个环形,分别是内径好外径,rosetype="area"表示是一个玫瑰样式的图形,is_label_show是显示标签及比例,center=[20,40]表示该图形的位置
pie.add("商品B",x,b,radius= [35,60],center= [70,40],rosetype="area",is_label_show= True )#center表示图表在的位置,,label_color= ["yellow",‘green‘]设置各部分的颜色,必须加中括号

pie.render("D:My DocumentsDesktopshashs.html")

4、折线图

from pyecharts import Line
sttr=["{}月".format(i) for i in range(1,13) ]

v1=[123,124,45,54,132,167,143,153,122,85,36,55]#降水量

v2=[26,36,59,45,45,78,69,77,65,24,25,22]#流失量

v3=[22,33,65,54,58,68,78,88,70,65,45,24]#蒸发量

v4=[10,8,15,21,24,28,37,36,29,21,18,17]#温度

line=Line ("折线图",title_pos=‘center‘)#折线图是图表的名字,title_pos标题放的位置,title_top="50%"是在上下的一半

line.use_theme("dark")

line.add("降水量",sttr ,v1,mark_point= ["max","min"],legend_top ="8%",label_color= ["r"])#legend_top是各标签的位置,labei_color是各图表的颜色

line.add("流失量",sttr ,v2,mark_point= ["max","min"],legend_top ="8%",label_color= ["r"])

line.add("蒸发量",sttr ,v3,mark_point= ["max","min"],legend_top ="8%",label_color= ["r"])

line.add("温度",sttr ,v4,mark_point= ["max","min"],legend_top ="8%",label_color= ["r"])

line.render("D:My DocumentsDesktopshashs.html")


以上是关于pyecharts的主要内容,如果未能解决你的问题,请参考以下文章

# yyds干货盘点 # Pyecharts绘图API总结

有人不会画地图||❤️这11个Python 6⃣️6⃣️6⃣️工具来帮忙❤️