赞
踩
准备工作:
pip install echarts-countries-pypkg
pip install echarts-china-provinces-pypkg
pip install echarts-china-cities-pypkg
pip install echarts-china-counties-pypkg
pip install echarts-china-misc-pypkg
pip install echarts-united-kingdom-pypkg
参考代码:
- from pyecharts.charts import Map # 新旧版本不同
- from pyecharts import options as opts #引入配置项入口
- import pandas as pd
-
-
- data = pd.read_excel('./test.xlsx')
- data1 = data.groupby('城市').count()
- num = pd.Series(data1.iloc[:,1]) # 切片取任意一列
- area = list(num.index)
- values = list(num)
- china_area = (
- Map()
- .add('',list(zip(area,values)), 'china-cities') # zip是新旧版本差异,china-cities指的是maptype
- .set_global_opts(
- title_opts=opts.TitleOpts(title='部分城市招聘数量'),
- visualmap_opts=opts.VisualMapOpts(
- min_=1,
- max_=1300, # num.max()
- is_piecewise=False) #分段
- )
- .set_series_opts(
- # 标签名称显示,默认为True
- label_opts=opts.LabelOpts(is_show=False, color="blue")
- )
- .render("map_chinacities.html")
- )
参考文章
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。