0%

pyecharts 绘制地图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 导入相关包
from pyecharts import options as opts
from pyecharts.charts import Map, Geo, Lin

data = pd.read_csv(r'C:\Users\1979\Desktop\处理后的数据\谷物产量(公吨)(2000-2017).csv')

value = data.iloc[:,18]
attr = data.iloc[:,0]
# 显示世界地图
def map_world() -> Map:
c = (
Map(init_opts=opts.InitOpts(
# 设置主题
theme='wonderland'))
.add("", [list(z) for z in zip(attr, value)], "world",is_map_symbol_show=False)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False),
itemstyle_opts={'normal': {

'opacity': 0.6
}}

)
.set_global_opts(
title_opts=opts.TitleOpts(title="Distribution map of global grain production",pos_right="center",pos_top="1%"),
visualmap_opts=opts.VisualMapOpts(max_=710000000,min_=10),
)
)
return c

country_ = map_world()
country_.render_notebook()

在这里插入图片描述

-------------    本文结束  感谢您的阅读    -------------