#pyecharts 分为 v0.5.X 和 v1 两个大版本,v0.5.X 和 v1 间不兼容,v1 是一个全新的版本,如果你是v1版本可以参考:https://github.com/pyecharts/pyecharts/issues/892
pip install pyecharts==0.5.11
#如果下面案例代码执行报错没有pyecharts-snapshot包解决如下
1.https://github.com/pyecharts/pyecharts-snapshot/releases github上下载v0.1.10的源码包
2.解压源码包,cmd命令进入目录下执行 python setup.py install 安装即可
#pyecharts v0.3.2以后,pyecharts 将不再自带地图 js 文件。如用户需要用到地图图表,可自行安装对应的地图文件包
# 地图包
全球国家地图: echarts-countries-pypkg 世界地图和 213 个国家,包括中国地图
中国省级地图: echarts-china-provinces-pypkg 23 个省,5 个自治区
中国市级地图: echarts-china-cities-pypkg 370 个中国城市
# windows 安装
pip install echarts-countries-pypkg
pip install echarts-china-provinces-pypkg
pip install echarts-china-cities-pypkg
# Linux 安装
sudo pip3 install echarts-countries-pypkg
sudo pip3 install echarts-china-provinces-pypkg
sudo pip3 install echarts-china-cities-pypkg
sudo pip3 install echarts-countries-pypkg
sudo pip3 install echarts-china-provinces-pypkg
sudo pip3 install echarts-china-cities-pypkg
**add() **:主要方法,用于添加图表的数据和设置各种配置项
show_config() :打印输出图表的所有配置项
**render() **:默认将会在根目录下生成一个 render.html 的文件,支持 path 参数,设置文件保存位置,如 render(r"e:my_first_chart.html"),文件用浏览器打开。
使用之前强调一点:就是python2.x和python3.x的编码问题,在python3.x中你可以把它看做默认是unicode编码,但在python2.x中并不是默认的,原因就在它的bytes对象定义的混乱,而pycharts是使用unicode编码来处理字符串和文件的,所以当你使用的是python2.x时,请务必在上方插入此代码:from __future__ import unicode_literals
from pyecharts import Bar
bar =Bar("我的第一个图表", "这里是副标题")
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90])
bar.show_config() #打印输出图表的所有配置项
bar.render()
多个数据
#导入柱状图-Bar
from pyecharts import Bar
#设置行名
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
#设置数据
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
#设置柱状图的主标题与副标题
bar = Bar("柱状图", "一年的降水量与蒸发量")
#添加柱状图的数据及配置项
bar.add("降水量", columns, data1, mark_line=["average"], mark_point=["max", "min"])# mark_point:标记点 mark_line:标记线
bar.add("蒸发量", columns, data2, mark_line=["average"], mark_point=["max", "min"])
#生成本地文件(默认为.html文件)
bar.render()
#如果不是在jupyter上跑的,那么会在你代码同级目录下生成一个html文件,用浏览器打开即可看到如下效果,图还是动态的。
x轴和y轴交换
from pyecharts import Bar
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
bar = Bar("柱状图", "一年的降水量与蒸发量")
bar.add("降水量", columns, data1, mark_line=["average"], mark_point=["max", "min"])
bar.add("蒸发量", columns, data2, mark_line=["average"], mark_point=["max", "min"], is_convert=True) #设置is_convert为True
bar.render()
数据堆叠
from pyecharts import Bar
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图数据堆叠示例")
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B", attr, v2, is_stack=True)
bar.render(r‘is_stack.html‘)
datazoom效果
from pyecharts import Bar
import random
attr = [‘{}天‘.format(i) for i in range(30)]
v1 = [random.randint(1,30) for _ in range(30)]
bar = Bar(‘Bar - datazoom - slider 示例‘)
bar.add(‘‘,attr,v1,is_label_show=True,is_datazoom_show=True)
bar.render(r‘datazoom.html‘)
#导入饼图Pie
from pyecharts import Pie
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
#设置主标题与副标题,标题设置居中,设置宽度为900
pie = Pie("饼状图", "一年的降水量与蒸发量",title_pos=‘center‘,width=900)
#加入数据,设置坐标位置为【25,50】
pie.add("降水量", columns, data1 ,center=[25,50],is_legend_show=False)
#加入数据,设置坐标位置为【75,50】,显示label标签
pie.add("蒸发量", columns, data2 ,center=[75,50],is_legend_show=False,is_label_show=True)
#保存图表
pie.render()
#导入箱型图Boxplot
from pyecharts import Boxplot
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
boxplot = Boxplot("箱形图", "一年的降水量与蒸发量")
x_axis = [‘降水量‘,‘蒸发量‘]
y_axis = [data1,data2]
#prepare_data方法可以将数据转为嵌套的 [min, Q1, median (or Q2), Q3, max]
yaxis = boxplot.prepare_data(y_axis)
boxplot.add("天气统计", x_axis, y_axis)
boxplot.render()
from pyecharts import Line
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
line = Line("折线图","一年的降水量与蒸发量")
#is_label_show是设置上方数据是否显示
line.add("降水量", columns, data1, is_label_show=True)
line.add("蒸发量", columns, data2, is_label_show=True)
line.render()
from pyecharts import Line
attr =["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 =[5, 20, 36, 10, 10, 100]
v2 =[55, 60, 16, 20, 15, 80]
line =Line("折线图示例")
line.add("商家A", attr, v1, mark_point=["average"])
line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
line.show_config()
line.render()
from pyecharts import Radar
radar = Radar("雷达图", "一年的降水量与蒸发量")
#由于雷达图传入的数据得为多维数据,所以这里需要做一下处理
radar_data1 = [[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]]
radar_data2 = [[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]]
#设置column的最大值,为了雷达图更为直观,这里的月份最大值设置有所不同
schema = [
("Jan", 5), ("Feb",10), ("Mar", 10),
("Apr", 50), ("May", 50), ("Jun", 200),
("Jul", 200), ("Aug", 200), ("Sep", 50),
("Oct", 50), ("Nov", 10), ("Dec", 5)
]
#传入坐标
radar.config(schema)
radar.add("降水量",radar_data1)
#一般默认为同一种颜色,这里为了便于区分,需要设置item的颜色
radar.add("蒸发量",radar_data2,item_color="#1C86EE")
radar.render()
from pyecharts import Scatter
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
scatter = Scatter("散点图", "一年的降水量与蒸发量")
#xais_name是设置横坐标名称,这里由于显示问题,还需要将y轴名称与y轴的距离进行设置
scatter.add("降水量与蒸发量的散点分布", data1,data2,xaxis_name="降水量",yaxis_name="蒸发量",
yaxis_name_gap=40)
scatter.render()
# -*- coding:utf-8 -*-
from pyecharts import EffectScatter
es = EffectScatter("动态散点图各种图形示例")
es.add("", [10], [10], symbol_size=20, effect_scale=3.5, effect_period=3, symbol="pin")
es.add("", [20], [20], symbol_size=12, effect_scale=4.5, effect_period=4, symbol="rect")
es.add("", [30], [30], symbol_size=30, effect_scale=5.5, effect_period=5, symbol="roundRect")
es.add("", [40], [40], symbol_size=10, effect_scale=6.5, effect_brushtype=‘fill‘, symbol="diamond")
es.add("", [50], [50], symbol_size=16, effect_scale=5.5, effect_period=3, symbol="arrow")
es.add("", [60], [60], symbol_size=6, effect_scale=2.5, effect_period=3, symbol="triangle")
es.render()
由于标题与图表是属于两个不同的控件,所以这里必须对下方的图表Line进行标题位置设置,否则会出现标题重叠的bug。
from pyecharts import Grid, Line, Bar
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
#设置折线图标题位置
line = Line("折线图","一年的降水量与蒸发量",title_top="45%")
line.add("降水量", columns, data1, is_label_show=True)
line.add("蒸发量", columns, data2, is_label_show=True)
bar = Bar("柱状图", "一年的降水量与蒸发量")
#添加柱状图的数据及配置项
bar.add("降水量", columns, data1, mark_line=["average"], mark_point=["max", "min"])
bar.add("蒸发量", columns, data2, mark_line=["average"], mark_point=["max", "min"])
grid = Grid()
#设置两个图表的相对位置
grid.add(bar, grid_bottom="60%")
grid.add(line, grid_top="60%")
grid.render()
from pyecharts import Line, Bar, Overlap
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
data2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
line = Line("折线图","一年的降水量与蒸发量",title_top="45%")
line.add("降水量", columns, data1, is_label_show=True)
line.add("蒸发量", columns, data2, is_label_show=True)
bar = Bar("柱状图-折线图合并", "一年的降水量与蒸发量")
bar.add("降水量", columns, data1, mark_point=["max", "min"])
bar.add("蒸发量", columns, data2, mark_point=["max", "min"])
overlap = Overlap()
overlap.add(bar)
overlap.add(line)
overlap.render()
add(name, attr, value, shape="circle", word_gap=20, word_size_range=None, rotate_step=45)
from pyecharts import WordCloud
name =[‘Sam S Club‘, ‘Macys‘, ‘Amy Schumer‘, ‘Jurassic World‘, ‘Charter Communications‘, ‘Chick Fil A‘, ‘Planet Fitness‘, ‘Pitch Perfect‘, ‘Express‘, ‘Home‘, ‘Johnny Depp‘, ‘Lena Dunham‘, ‘Lewis Hamilton‘, ‘KXAN‘, ‘Mary Ellen Mark‘, ‘Farrah Abraham‘, ‘Rita Ora‘, ‘Serena Williams‘, ‘NCAA baseball tournament‘, ‘Point Break‘]
value =[10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112, 965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265]
wordcloud =WordCloud(width=1300, height=620)
wordcloud.add("", name, value, word_size_range=[20, 100])
wordcloud.show_config()
wordcloud.render()
#可以通过shape参数来选择词云图的形状
wordcloud =WordCloud(width=1300, height=620)
wordcloud.add("", name, value, word_size_range=[30, 100], shape=‘diamond‘)
wordcloud.show_config()
wordcloud.render()
add(name, attr, value, type="scatter", maptype=‘china‘, coordinate_region=‘中国‘, symbol_size=12, border_color="#111", geo_normal_color="#323c48", geo_emphasis_color="#2a333d", geo_cities_coords=None, is_roam=True, **kwargs)
中国
。具体的国家/地区映射表参照 countries_regions_db.json。更多地理坐标信息可以参考 数据集篇from pyecharts import Geo
data =[("海门", 9), ("鄂尔多斯", 12), ("招远", 12), ("舟山", 12), ("齐齐哈尔", 14), ("盐城", 15)]
geo =Geo("全国主要城市空气质量", "data from pm2.5", title_color="#fff", title_pos="center", width=1200, height=600, background_color=‘#404a59‘)
attr, value =geo.cast(data)
geo.add("", attr, value, type="effectScatter", is_random=True, effect_scale=5)
geo.show_config()
geo.render()
from pyecharts import Geo
data = [
("海门", 9),("鄂尔多斯", 12),("招远", 12),("舟山", 12),("齐齐哈尔", 14),("盐城", 15),
("赤峰", 16),("青岛", 18),("乳山", 18),("金昌", 19),("泉州", 21),("莱西", 21),
("日照", 21),("胶南", 22),("南通", 23),("拉萨", 24),("云浮", 24),("梅州", 25),
("文登", 25),("上海", 25),("攀枝花", 25),("威海", 25),("承德", 25),("厦门", 26),
("汕尾", 26),("潮州", 26),("丹东", 27),("太仓", 27),("曲靖", 27),("烟台", 28),
("福州", 29),("瓦房店", 30),("即墨", 30),("抚顺", 31),("玉溪", 31),("张家口", 31),
("阳泉", 31),("莱州", 32),("湖州", 32),("汕头", 32),("昆山", 33),("宁波", 33),
("湛江", 33),("揭阳", 34),("荣成", 34),("连云港", 35),("葫芦岛", 35),("常熟", 36),
("东莞", 36),("河源", 36),("淮安", 36),("泰州", 36),("南宁", 37),("营口", 37),
("惠州", 37),("江阴", 37),("蓬莱", 37),("韶关", 38),("嘉峪关", 38),("广州", 38),
("延安", 38),("太原", 39),("清远", 39),("中山", 39),("昆明", 39),("寿光", 40),
("盘锦", 40),("长治", 41),("深圳", 41),("珠海", 42),("宿迁", 43),("咸阳", 43),
("铜川", 44),("平度", 44),("佛山", 44),("海口", 44),("江门", 45),("章丘", 45),
("肇庆", 46),("大连", 47),("临汾", 47),("吴江", 47),("石嘴山", 49),("沈阳", 50),
("苏州", 50),("茂名", 50),("嘉兴", 51),("长春", 51),("胶州", 52),("银川", 52),
("张家港", 52),("三门峡", 53),("锦州", 54),("南昌", 54),("柳州", 54),("三亚", 54),
("自贡", 56),("吉林", 56),("阳江", 57),("泸州", 57),("西宁", 57),("宜宾", 58),
("呼和浩特", 58),("成都", 58),("大同", 58),("镇江", 59),("桂林", 59),("张家界", 59),
("宜兴", 59),("北海", 60),("西安", 61),("金坛", 62),("东营", 62),("牡丹江", 63),
("遵义", 63),("绍兴", 63),("扬州", 64),("常州", 64),("潍坊", 65),("重庆", 66),
("台州", 67),("南京", 67),("滨州", 70),("贵阳", 71),("无锡", 71),("本溪", 71),
("克拉玛依", 72),("渭南", 72),("马鞍山", 72),("宝鸡", 72),("焦作", 75),("句容", 75),
("北京", 79),("徐州", 79),("衡水", 80),("包头", 80),("绵阳", 80),("乌鲁木齐", 84),
("枣庄", 84),("杭州", 84),("淄博", 85),("鞍山", 86),("溧阳", 86),("库尔勒", 86),
("安阳", 90),("开封", 90),("济南", 92),("德阳", 93),("温州", 95),("九江", 96),
("邯郸", 98),("临安", 99),("兰州", 99),("沧州", 100),("临沂", 103),("南充", 104),
("天津", 105),("富阳", 106),("泰安", 112),("诸暨", 112),("郑州", 113),("哈尔滨", 114),
("聊城", 116),("芜湖", 117),("唐山", 119),("平顶山", 119),("邢台", 119),("德州", 120),
("济宁", 120),("荆州", 127),("宜昌", 130),("义乌", 132),("丽水", 133),("洛阳", 134),
("秦皇岛", 136),("株洲", 143),("石家庄", 147),("莱芜", 148),("常德", 152),("保定", 153),
("湘潭", 154),("金华", 157),("岳阳", 169),("长沙", 175),("衢州", 177),("廊坊", 193),
("菏泽", 194),("合肥", 229),("武汉", 273),("大庆", 279)]
geo = Geo(
"全国主要城市空气质量",
"data from pm2.5",
title_color="#fff",
title_pos="center",
width=1200,
height=600,
background_color="#404a59",
)
attr, value = geo.cast(data)
geo.add(
"",
attr,
value,
visual_range=[0, 200],
visual_text_color="#fff",
symbol_size=15,
is_visualmap=True,
)
geo.render()
这里也要先说明一点因为echarts里面有的地点可能没有,一旦添加了没有的在这里面,将会生成一个空的图。
有四个解决办法:
一是最简单的把不存在删掉;
二是到百度地图api里把找不到的地方的经纬度加进原始的包里(这个办法大家可以参看这位大佬的博客https://www.jb51.net/article/163958.htm);
三是如果你的数据在地图中并没有坐标城市,可以通过geo_cities_coords 自己进行添加,GeoLine图同样如此
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: jyroy
from pyecharts import Geo
if __name__ == ‘__main__‘:
list_city_name=["100,30-1","130,40-2"]
list_num = [["value1","value2"],["value3"]]
geo_cities_coords = {"100,30-1":[100,30],"130,40-2":[130,40]}
geo = Geo("Geo 实例")
geo.add("",list_city_name, list_num, geo_cities_coords=geo_cities_coords)
geo.render()
四是如果你是批量的导入导入数据(类似从数据库中),异常数据并不想插入到地图中去,可以通过try...except...来清除这少部分的异常数据,如下代码
for n, m in data.items(): #data是我从数据库中读取的城市的字典数据
list_1 = []
list_2 = []
list_1.append(n)
list_2.append(m)
try:
geo.add("", list_1, list_2, visual_range=[0, 3000], visual_text_color="#fff", symbol_size=15, is_visualmap=True)
except Exception as e:
pass
from pyecharts import Map
province_distribution = {‘河南‘: 45.23, ‘北京‘: 37.56, ‘河北‘: 21, ‘辽宁‘: 12, ‘江西‘: 6, ‘上海‘: 20, ‘安徽‘: 10, ‘江苏‘: 16, ‘湖南‘: 9, ‘浙江‘: 13, ‘海南‘: 2, ‘广东‘: 22, ‘湖北‘: 8, ‘黑龙江‘: 11, ‘澳门‘: 1, ‘陕西‘: 11, ‘四川‘: 7, ‘内蒙古‘: 3, ‘重庆‘: 3, ‘云南‘: 6, ‘贵州‘: 2, ‘吉林‘: 3, ‘山西‘: 12, ‘山东‘: 11, ‘福建‘: 4, ‘青海‘: 1, ‘舵主科技,质量保证‘: 1, ‘天津‘: 1, ‘其他‘: 1}
provice=list(province_distribution.keys())
values=list(province_distribution.values())
# maptype=‘china‘ 只显示全国直辖市和省级
# 数据只能是省名和直辖市的名称
map = Map("中国地图",‘中国地图‘, width=1200, height=600)
map.add("", provice, values, visual_range=[0, 50], maptype=‘china‘, is_visualmap=True,
visual_text_color=‘#000‘)
map.show_config()
map.render()
河南地图 数据必须是省内放入城市名
from pyecharts import Map
# 城市 -- 指定省的城市 xx市
city = [‘郑州市‘, ‘安阳市‘, ‘洛阳市‘, ‘濮阳市‘, ‘南阳市‘, ‘开封市‘, ‘商丘市‘, ‘信阳市‘, ‘新乡市‘]
values2 = [1.07, 3.85, 6.38, 8.21, 2.53, 4.37, 9.38, 4.29, 6.1]
map2 = Map("河南地图",‘河南‘, width=1200, height=600)
map2.add(‘河南‘, city, values2, visual_range=[1, 10], maptype=‘河南‘, is_visualmap=True, visual_text_color=‘#000‘)
map2.render()
商丘地图 数据为商丘市下的区县
from pyecharts import Map
# 区县 -- 具体城市内的区县 xx县
quxian = [‘夏邑县‘, ‘民权县‘, ‘梁园区‘, ‘睢阳区‘, ‘柘城县‘, ‘宁陵县‘]
values3 = [3, 5, 7, 8, 2, 4]
map3 = Map("商丘地图",‘商丘‘, width=1200, height=600)
map3.add("商丘", quxian, values3, visual_range=[1, 10], maptype=‘商丘‘, is_visualmap=True,
visual_text_color=‘#000‘)
map3.render(path="render.html")
from pyecharts import Map
#世界地图数据
value = [95.1, 23.2, 43.3, 66.4, 88.5]
attr= ["China", "Canada", "Brazil", "Russia", "United States"]
map0 = Map("世界地图示例", width=1200, height=600)
map0.add("世界地图", attr, value, maptype="world", is_visualmap=True, visual_text_color=‘#000‘)
map0.render()
add(name, x_axis, y_axis, **kwargs)
from pyecharts import Kline
v1 = [[2320.26, 2320.26, 2287.3, 2362.94], [2300, 2291.3, 2288.26, 2308.38],
[2295.35, 2346.5, 2295.35, 2345.92], [2347.22, 2358.98, 2337.35, 2363.8],
[2360.75, 2382.48, 2347.89, 2383.76], [2383.43, 2385.42, 2371.23, 2391.82],
[2377.41, 2419.02, 2369.57, 2421.15], [2425.92, 2428.15, 2417.58, 2440.38],
[2411, 2433.13, 2403.3, 2437.42], [2432.68, 2334.48, 2427.7, 2441.73],
[2430.69, 2418.53, 2394.22, 2433.89], [2416.62, 2432.4, 2414.4, 2443.03],
[2441.91, 2421.56, 2418.43, 2444.8], [2420.26, 2382.91, 2373.53, 2427.07],
[2383.49, 2397.18, 2370.61, 2397.94], [2378.82, 2325.95, 2309.17, 2378.82],
[2322.94, 2314.16, 2308.76, 2330.88], [2320.62, 2325.82, 2315.01, 2338.78],
[2313.74, 2293.34, 2289.89, 2340.71], [2297.77, 2313.22, 2292.03, 2324.63],
[2322.32, 2365.59, 2308.92, 2366.16], [2364.54, 2359.51, 2330.86, 2369.65],
[2332.08, 2273.4, 2259.25, 2333.54], [2274.81, 2326.31, 2270.1, 2328.14],
[2333.61, 2347.18, 2321.6, 2351.44], [2340.44, 2324.29, 2304.27, 2352.02],
[2326.42, 2318.61, 2314.59, 2333.67], [2314.68, 2310.59, 2296.58, 2320.96],
[2309.16, 2286.6, 2264.83, 2333.29], [2282.17, 2263.97, 2253.25, 2286.33],
[2255.77, 2270.28, 2253.31, 2276.22]]
kline = Kline("K 线图示例")
kline.add("日K", ["2018/9/{}".format(i + 1) for i in range(30)], v1)
kline.render()
from pyecharts import Gauge
# 仪表盘
gauge = Gauge("仪表盘")
gauge.add(‘业务指标‘, ‘完成率‘, 66.66)
gauge.show_config()
gauge.render()
from pyecharts import Liquid
liquid =Liquid("水球图")
liquid.add("Liquid", [0.6])
liquid.show_config()
liquid.render(path=‘1.html‘)
# 圆形水球
liquid2 =Liquid("水球图示例")
liquid2.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_outline_show=False)
liquid2.show_config()
liquid2.render()
# 菱形水球
liquid3 =Liquid("水球图示例")
liquid3.add("Liquid", [0.6, 0.5, 0.4, 0.3], is_liquid_animation=False, shape=‘diamond‘)
liquid3.show_config()
liquid3.render(path=‘./data/03-03菱形水球.html‘)
# -*- coding:utf-8 -*-
from pyecharts import Scatter3D
import random
data = [[random.randint(0, 100), random.randint(0, 100), random.randint(0, 100)] for _ in range(80)]
range_color = [‘#313695‘, ‘#4575b4‘, ‘#74add1‘, ‘#abd9e9‘, ‘#e0f3f8‘, ‘#ffffbf‘,
‘#fee090‘, ‘#fdae61‘, ‘#f46d43‘, ‘#d73027‘, ‘#a50026‘]
scatter3D = Scatter3D("3D 散点图示例", width=1200, height=600)
scatter3D.add("", data, is_visualmap=True, visual_range_color=range_color)
scatter3D.render()
原文:https://www.cnblogs.com/chenwenyin/p/13583494.html