Python:创建地图(笔记)

from pyecharts.charts import Map
from pyecharts.options import VisualMapOpts

map = Map()
data = [
    ("北京市", 9),
    ("上海市", 90),
    ("湖南省", 69),
    ("台湾省", 199),
    ("安徽省", 6),
    ("广州市", 399),
    ("湖北省", 599)
]
map.add("地图", data, "china")

# 设置全局选项
map.set_global_opts(
    visualmap_opts=VisualMapOpts(
        # 展示颜色为true
        is_show=True,
        # 设置手动调整范围为true
        is_piecewise=True,
        # 设置颜色范围
        pieces=[
            {"min":1,"max":9,"label":"1-9","color":"#00F5FF"},
            {"min":10,"max":99,"label":"10-99","color":"#008B45"},
             {"min":100,"max":999,"label":"100-999","color":"#8470FF"},
        ]


    )
)
# 生成地图
map.render()

你可能感兴趣的:(python)