用pyecharts画地图(世界地图、中国省级地图、市级地图、某省市级地图、某市县级地图
pyecharts-世界地图
from pyecharts.charts import Map # 注意这里与老版本pyecharts调用的区别
from pyecharts import options as opts
import random
country = ['China', 'Canada', 'France', 'Japan', 'Russia', 'USA']
data_world = [(i, random.randint(100, 200)) for i in country]
world = (
Map()
.add('', # 此处没取名,所以空着
data_world, # 数据
'world') # 地图类型
.set_global_opts(
title_opts=opts.TitleOpts(title='World Map'),
visualmap_opts=opts.VisualMapOpts(
max_=200,
min_=100,
is_piecewise=True) # 定义图例为分段型,默认为连续的图例
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.render(path='世界地图.html')
)
pyecharts-中国省级地图
city = ['北京', '天津', '上海', '广州', '阿拉善盟', '株洲']
data_city = [(i, random.randint(100, 200)) for i in city]
china_city = (
Map()
.add(
"",
data_city,
"china-cities",
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(
title_opts=opts.TitleOpts(title="中国市级地图"),
visualmap_opts=opts.VisualMapOpts(
min_=100,
max_=200,
is_piecewise=True
),
)
.render("中国地级市地图.html")
)
?
pyecharts-中国市级地图
city = ['北京', '天津', '上海', '广州', '阿拉善盟', '株洲']
data_city = [(i, random.randint(100, 200)) for i in city]
china_city = (
Map()
.add(
"",
data_city,
"china-cities",
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(
title_opts=opts.TitleOpts(title="中国市级地图"),
visualmap_opts=opts.VisualMapOpts(
min_=100,
max_=200,
is_piecewise=True
),
)
.render("中国地级市地图.html")
)
?
pyecharts-某省市级地图
counties = (
Map()
.add(
"",
[['博罗县', 100]],
"惠州",
label_opts=opts.LabelOpts(is_show=False)
)
.set_global_opts(
title_opts=opts.TitleOpts(title="中国某市区县地图"),
visualmap_opts=opts.VisualMapOpts(),
)
.render("某市的区县地图.html")
)
?
pyecharts-某市县级地图
counties = (
Map()
.add(
"",
[['博罗县', 100]],
"惠州",
label_opts=opts.LabelOpts(is_show=False)
)
.set_global_opts(
title_opts=opts.TitleOpts(title="中国某市区县地图"),
visualmap_opts=opts.VisualMapOpts(),
)
.render("某市的区县地图.html")
)
?