Skip to content

Commit 90ff08d

Browse files
author
xuming06
committed
add pyechart demo.
1 parent 27903f1 commit 90ff08d

7 files changed

Lines changed: 161 additions & 1 deletion

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
bar = Bar("我的第一个图表", "这里是副标题")
1010
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90],is_more_utils=True)
1111
# bar.print_echarts_options() # 该行只为了打印配置项,方便调试时使用
12-
bar.render() # 生成本地 HTML 文件
12+
bar.render("bar.html") # 生成本地 HTML 文件
13+

32echart/city_map_demo.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from pyecharts import Map
8+
9+
value = [20, 190, 253, 77, 65]
10+
attr = ['汉阳区', '汉口区', '武昌区', '洪山区', '青山区']
11+
map = Map("武汉地图示例", width=1200,
12+
height=600)
13+
map.add("", attr, value, maptype='武汉',
14+
is_visualmap=True,
15+
visual_text_color='#000', is_label_show=True)
16+
map.render("city_map.html")

32echart/country_map_demo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from pyecharts import Map
8+
value = [155, 10, 66, 78]
9+
attr = ["福建", "山东", "北京", "上海"]
10+
map = Map("全国地图示例",height=720,width=800)
11+
map.add("", attr, value, maptype='china')
12+
map.render("country_map.html")
13+

32echart/geo_map_demo.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from pyecharts import Geo
8+
9+
data = [
10+
("海门", 9),("鄂尔多斯", 12),("招远", 12),("舟山", 12),("齐齐哈尔", 14),("盐城", 15),
11+
("赤峰", 16),("青岛", 18),("乳山", 18),("金昌", 19),("泉州", 21),("莱西", 21),
12+
("日照", 21),("胶南", 22),("南通", 23),("拉萨", 24),("云浮", 24),("梅州", 25),
13+
("文登", 25),("上海", 25),("攀枝花", 25),("威海", 25),("承德", 25),("厦门", 26),
14+
("汕尾", 26),("潮州", 26),("丹东", 27),("太仓", 27),("曲靖", 27),("烟台", 28),
15+
("福州", 29),("瓦房店", 30),("即墨", 30),("抚顺", 31),("玉溪", 31),("张家口", 31),
16+
("阳泉", 31),("莱州", 32),("湖州", 32),("汕头", 32),("昆山", 33),("宁波", 33),
17+
("湛江", 33),("揭阳", 34),("荣成", 34),("连云港", 35),("葫芦岛", 35),("常熟", 36),
18+
("东莞", 36),("河源", 36),("淮安", 36),("泰州", 36),("南宁", 37),("营口", 37),
19+
("惠州", 37),("江阴", 37),("蓬莱", 37),("韶关", 38),("嘉峪关", 38),("广州", 38),
20+
("延安", 38),("太原", 39),("清远", 39),("中山", 39),("昆明", 39),("寿光", 40),
21+
("盘锦", 40),("长治", 41),("深圳", 41),("珠海", 42),("宿迁", 43),("咸阳", 43),
22+
("铜川", 44),("平度", 44),("佛山", 44),("海口", 44),("江门", 45),("章丘", 45),
23+
("肇庆", 46),("大连", 47),("临汾", 47),("吴江", 47),("石嘴山", 49),("沈阳", 50),
24+
("苏州", 50),("茂名", 50),("嘉兴", 51),("长春", 51),("胶州", 52),("银川", 52),
25+
("张家港", 52),("三门峡", 53),("锦州", 54),("南昌", 54),("柳州", 54),("三亚", 54),
26+
("自贡", 56),("吉林", 56),("阳江", 57),("泸州", 57),("西宁", 57),("宜宾", 58),
27+
("呼和浩特", 58),("成都", 58),("大同", 58),("镇江", 59),("桂林", 59),("张家界", 59),
28+
("宜兴", 59),("北海", 60),("西安", 61),("金坛", 62),("东营", 62),("牡丹江", 63),
29+
("遵义", 63),("绍兴", 63),("扬州", 64),("常州", 64),("潍坊", 65),("重庆", 66),
30+
("台州", 67),("南京", 67),("滨州", 70),("贵阳", 71),("无锡", 71),("本溪", 71),
31+
("克拉玛依", 72),("渭南", 72),("马鞍山", 72),("宝鸡", 72),("焦作", 75),("句容", 75),
32+
("北京", 79),("徐州", 79),("衡水", 80),("包头", 80),("绵阳", 80),("乌鲁木齐", 84),
33+
("枣庄", 84),("杭州", 84),("淄博", 85),("鞍山", 86),("溧阳", 86),("库尔勒", 86),
34+
("安阳", 90),("开封", 90),("济南", 92),("德阳", 93),("温州", 95),("九江", 96),
35+
("邯郸", 98),("临安", 99),("兰州", 99),("沧州", 100),("临沂", 103),("南充", 104),
36+
("天津", 105),("富阳", 106),("泰安", 112),("诸暨", 112),("郑州", 113),("哈尔滨", 114),
37+
("聊城", 116),("芜湖", 117),("唐山", 119),("平顶山", 119),("邢台", 119),("德州", 120),
38+
("济宁", 120),("荆州", 127),("宜昌", 130),("义乌", 132),("丽水", 133),("洛阳", 134),
39+
("秦皇岛", 136),("株洲", 143),("石家庄", 147),("莱芜", 148),("常德", 152),("保定", 153),
40+
("湘潭", 154),("金华", 157),("岳阳", 169),("长沙", 175),("衢州", 177),("廊坊", 193),
41+
("菏泽", 194),("合肥", 229),("武汉", 273),("大庆", 279)]
42+
43+
geo = Geo(
44+
"全国主要城市空气质量",
45+
"data from pm2.5",
46+
title_color="#fff",
47+
title_pos="center",
48+
width=1200,
49+
height=600,
50+
background_color="#404a59",
51+
)
52+
attr, value = geo.cast(data)
53+
geo.add(
54+
"",
55+
attr,
56+
value,
57+
visual_range=[0, 200],
58+
visual_text_color="#fff",
59+
symbol_size=15,
60+
is_visualmap=True,
61+
)
62+
geo.render("geo_map.html")
63+
64+
geo = Geo(
65+
"全国主要城市空气质量",
66+
"data from pm2.5",
67+
title_color="#fff",
68+
title_pos="center",
69+
width=1200,
70+
height=600,
71+
background_color="#404a59",
72+
)
73+
attr, value = geo.cast(data)
74+
geo.add(
75+
"",
76+
attr,
77+
value,
78+
type="heatmap",
79+
is_visualmap=True,
80+
visual_range=[0, 300],
81+
visual_text_color="#fff",
82+
)
83+
geo.render("geo_map_heat.html")

32echart/geo_place_lat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from pyecharts.datasets.coordinates import get_coordinate,search_coordinates_by_keyword
8+
9+
coordinate = get_coordinate('武汉', region="中国")
10+
print(coordinate)
11+
12+
ret = search_coordinates_by_keyword("东湖区")
13+
print(ret)

32echart/province_map_demo.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from pyecharts import Map
8+
value = [20, 190, 253, 77, 65]
9+
attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市']
10+
map = Map("广东地图示例", width=1200,
11+
height=600)
12+
map.add("", attr, value, maptype='广东',
13+
is_visualmap=True,
14+
visual_text_color='#000',is_label_show=True)
15+
map.render("prov_map.html")

32echart/wordcloud_demo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
@author:XuMing([email protected])
4+
@description:
5+
"""
6+
7+
from pyecharts import WordCloud
8+
name_list = ['Sam S Club', 'Macys', 'Amy Schumer', 'Jurassic World',
9+
'Charter Communications','Chick Fil A', 'Planet Fitness',
10+
'Pitch Perfect', 'Express','Home', 'Johnny Depp',
11+
'Lena Dunham', 'Lewis Hamilton', 'KXAN', 'Mary EllenMark',
12+
'Farrah Abraham','Rita Ora', 'Serena Williams',
13+
'NCAA baseball tournament','Point Break']
14+
value_list = [10000, 6181, 4386, 4055, 2467, 2244,
15+
1898, 1484, 1112,965, 847, 582, 555,
16+
550, 462, 366, 360, 282, 273, 265]
17+
wordcloud = WordCloud(width=800, height=500)
18+
wordcloud.add("", name_list, value_list, word_size_range=[20, 100])
19+
wordcloud.render("wordcloud.html")

0 commit comments

Comments
 (0)