Python精美地理可视化绘制——以中国历年GDP数据为例
IT共享之家
共 4677字,需浏览 10分钟
·
2021-04-12 10:05
点击上方“IT共享之家”,进行关注
回复“资料”可获赠Python学习福利
专栏作者:zch,经管专业研一在读,Python数据分析及可视化爱好者。公众号后台回复入群,拉你进技术群与大佬们近距离交流。
01
关于绘图数据
02
地理可视化
import pandas as pd
from pyecharts.charts import Map
import pyecharts.options as opts
frame = pd.read_csv('C:\\Users\\dell\\Desktop\\分省年度数据2.csv',encoding='GBK')
map = Map()
map.add("我国地区的GDP",frame[['地区','2019年']].values.tolist(),"china")
map.set_global_opts(visualmap_opts=opts.VisualMapOpts(min_=500,max_=12000))
map.render("2019年全国各地区GDP.html")
geo.set_global_opts(visualmap_opts=opts.VisualMapOpts(
is_piecewise=True,
pieces=[
{"min":0,"max":10000,"label":"1~10000","color":"cyan"},
{"min":10001,"max":20000,"label":"10001~20000","color":"yellow"},
{"min":20001,"max":50000,"label":"20001~50000","color":"orange"},
{"min":50001,"max":80000,"label":"50001~80000","color":"coral"},
{"min":80001,"max":120000,"label":"80001~120000","color":"red"},
]
))
import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Map, Timeline
frame = pd.read_csv('C:\\Users\\dell\\Desktop\\分省年度数据2.csv',encoding='GBK')
tl = Timeline()
for i in range(2010, 2020):
map0 = (
Map()
.add("省份",frame[['地区',str(i)+'年']].values.tolist(), "china")
.set_global_opts(
title_opts=opts.TitleOpts(title="Map-{}年GDP(亿元)".format(i)),
visualmap_opts=opts.VisualMapOpts(
is_piecewise=True,
pieces=[
{"min":0,"max":10000,"label":"1~10000","color":"cyan"},
{"min":10001,"max":20000,"label":"10001~20000","color":"yellow"},
{"min":20001,"max":50000,"label":"20001~50000","color":"orange"},
{"min":50001,"max":80000,"label":"50001~80000","color":"coral"},
{"min":80001,"max":120000,"label":"80001~12000","color":"red"},
] ),))
tl.add(map0, "{}年".format(i))
tl.render("2010~2019年全国各地区GDP.html")
03
小结
看完本文有收获?请转发分享给更多的人
IT共享之家
入群请在微信后台回复【入群】
------------------- End -------------------
往期精彩文章推荐:
评论