小白学Python(16)——pyecharts 绘制地理图表 Geo

Geo-基本示例

 1 from example.commons import Faker
 2 from pyecharts import options as opts
 3 from pyecharts.charts import Geo
 4 from pyecharts.globals import ChartType, SymbolType
 5 
 6 geo = (
 7         Geo()
 8         .add_schema(maptype="china")
 9         .add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
10         .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
11         .set_global_opts(
12             visualmap_opts=opts.VisualMapOpts(),
13             title_opts=opts.TitleOpts(title="Geo-基本示例"),
14         )
15     )
16 geo.render()

Geo-Lines-background

 

 1 from example.commons import Faker
 2 from pyecharts import options as opts
 3 from pyecharts.charts import Geo
 4 from pyecharts.globals import ChartType, SymbolType
 5 
 6 geo = (
 7        Geo()
 8         .add_schema(
 9             maptype="china",
10             itemstyle_opts=opts.ItemStyleOpts(color="#323c48", border_color="#111"),
11         )
12         .add(
13             "",
14             [("广州", 55), ("北京", 66), ("杭州", 77), ("重庆", 88)],
15             type_=ChartType.EFFECT_SCATTER,
16             color="white",
17         )
18         .add(
19             "geo",
20             [("广州", "上海"), ("广州", "北京"), ("广州", "杭州"), ("广州", "重庆")],
21             type_=ChartType.LINES,
22             effect_opts=opts.EffectOpts(
23                 symbol=SymbolType.ARROW, symbol_size=6, color="blue"
24             ),
25             linestyle_opts=opts.LineStyleOpts(curve=0.2),
26         )
27         .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
28         .set_global_opts(title_opts=opts.TitleOpts(title="Geo-Lines-background"))
29     )
30 
31 geo.render()

Geo-EffectScatter

 1 from example.commons import Faker
 2 from pyecharts import options as opts
 3 from pyecharts.charts import Geo
 4 from pyecharts.globals import ChartType, SymbolType
 5 
 6 geo = (
 7      Geo()
 8         .add_schema(maptype="china")
 9         .add(
10             "geo",
11             [list(z) for z in zip(Faker.provinces, Faker.values())],
12             type_=ChartType.EFFECT_SCATTER,
13         )
14         .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
15         .set_global_opts(title_opts=opts.TitleOpts(title="Geo-EffectScatter"))
16     )
17 
18 geo.render()

 Map-基本示例

 1 from example.commons import Faker
 2 from pyecharts import options as opts
 3 from pyecharts.charts import Map
 4 
 5 map=(
 6     Map()
 7         .add("商家A", [list(z) for z in zip(Faker.provinces, Faker.values())], "china")
 8         .set_global_opts(title_opts=opts.TitleOpts(title="Map-基本示例"))
 9     )
10 
11 map.render()

 Map-VisualMap(连续型)

 1 from example.commons import Faker
 2 from pyecharts import options as opts
 3 from pyecharts.charts import Map
 4 
 5 map=(
 6      Map()
 7         .add("商家A", [list(z) for z in zip(Faker.provinces, Faker.values())], "china")
 8         .set_global_opts(
 9             title_opts=opts.TitleOpts(title="Map-VisualMap(连续型)"),
10             visualmap_opts=opts.VisualMapOpts(max_=200),
11         )
12     )
13 map.render()

 

 

posted @ 2019-08-23 16:56  徐海建  阅读(7029)  评论(0编辑  收藏  举报