Loading

pyecharts 绘制地图

同个人网站 https://www.serendipper-x.cn/,欢迎访问 !

# 导入相关包
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()

在这里插入图片描述

posted @ 2021-03-01 09:27  XiaoJ_c  阅读(44)  评论(0编辑  收藏  举报