目录
1.安装pyecharts
2.查看pyecharts版本
3.Map
4.Geo
5. 去掉地图中的小红点
pip install pyecharts==0.5.11
import pyecharts
pyecharts.__version__
Map是实现地图区域可视化,是区域可视化. Map
依赖的是额外安装的地图包,如:
安装额外包:
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 import Map
districts1=[
"中西区","湾仔区","东区","南区","油尖旺区","深水埗区","九龍城区","黃大仙区","观塘区","荃湾区","屯門区","元朗区","北区","大埔区","西貢区",
"沙田区","葵青区","离岛区"
]
value1 = [20000,30000,40000,34546,33567,22467,
66700,233366,89900,35600,68480,56000,
65900,56700,45000,56700,98760,34630
]#随机输入值
map = Map("", "", title_pos='center', width=1000, height=1000)
map.add("",
districts1, value1, maptype='香港',
is_visualmap=True,
is_map_symbol_show=False,#去掉地图中的小红点
visual_range=[min(value1), max(value1)],
is_label_show=False ,
label_formatter='{b}'+'{c}',
)
map.render("house_price_of_HongKong_Map.html")
map
Geo是实现的地图散点图可视化,散点也可以根据数值大小而变化. Pyecharts中Geo函数常用参数详解
add_coordinate()
方法添加经纬度坐标
栗子:
from pyecharts import Geo
districts=['白云区', '从化区', '番禺区', '海珠区', '花都区', '黄埔区', '荔湾区', '南沙区', '天河区', '越秀区', '增城区']
value = [ 100, 200, 300,400, 500,600,700,800,900,1000, 1100]
geo = Geo("Geo地图示例", "",title_pos='center', width=1000, height=1000)
geo.add_coordinate('南沙区', 113.525165,22.801624)
geo.add_coordinate('白云区', 113.273238,23.3)
geo.add_coordinate('从化区', 113.586679,23.548748)
geo.add_coordinate('增城区', 113.810627,23.261465)
geo.add_coordinate('番禺区', 113.384152,22.937556)
geo.add_coordinate('海珠区', 113.361575,23.08)
geo.add_coordinate('花都区', 113.220463,23.403744)
geo.add_coordinate('黄埔区', 113.550541,23.24)
geo.add_coordinate('荔湾区', 113.23,23.05)
geo.add_coordinate('天河区', 113.361575,23.20)
geo.add_coordinate('越秀区', 113.266835,23.128537)
geo.add("",
districts, value, maptype='广州',
is_visualmap=True,
is_label_show=True ,
visual_range=[min(value), max(value)],
label_formatter='{b}'
)
geo.render("population_density_of_guangzhou.html")
is_map_symbol_show=False这句是去掉小红点的,is_label_show=True是将名称标注在地图上的。
https://blog.csdn.net/weixin_36677127/article/details/83188810
Reference:
https://blog.csdn.net/weixin_41563274/article/details/82904106?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control
https://blog.csdn.net/qq_37851620/article/details/92802159
https://zhuanlan.zhihu.com/p/36336689
pyecharts官网