免费在线Ai工具箱 /python制作图表
阅读主题
正文字体
字体大小

05.地图

本节953字2025-03-03 17:18:33
"""
author:少校
create Time:2025/2/28 9:39
越努力越幸运
"""
from pyecharts.charts import Map
from pyecharts import options
# 1.创建图表对象
map1 = Map()
# 2. 添加数据
map1.add(
    '人均GDP',
    [('四川省', 77315), ('北京市', 228011), ('上海市', 216834),
     ('湖南省', 57890), ('青海省', 49876), ('广东省', 139080), ('山西省', 68905),
     ('内蒙古自治区', 85621)],
    zoom=1.5,       # 默认大小为原地图的1.5倍
    pos_top=100,
    max_scale_limit=3,      # 缩放最大倍数为3
    min_scale_limit=0.7     # 缩放最小倍数为0.7
)
# 3. 添加配置
map1.set_global_opts(
    visualmap_opts=options.VisualMapOpts(
        is_show=True,
        max_=230000,
        min_=40000,
        is_piecewise=True
    ),
    legend_opts=options.LegendOpts(
        is_show=False
    ),
    title_opts=options.TitleOpts(
        title='2023全国人均GDP',
        pos_left='340'
    )
)

#4.生成地图
map1.render("charts/GDP地图.html")


网友评论

相关作品