pyecharts 区县

from pyecharts.charts import Map
from pyecharts import options

# 准备地图对象
map = Map()

# 准备数据,注意准备的数据必须是准确的,比如北京智能写北京市,湖南只能写湖南省,香港只能写香港特别行政区,西藏只能写西藏自治区等等,否则会出现数据不显示问题。
data = [("北京市", 100), ("上海市", 199), ("湖南省", 299), ("台湾省", 199), ("安徽省", 299), ("广州省", 399),
("湖北省", 599)]

# 添加数据(地图名称 地图数据 地图类型(默认))
map.add("测试地图", data, "china")

"""
设置全局变量
VisualMapOpts:视觉映射配置项
is_show: bool = True,是否显示视觉映射配置
is_piecewise: bool = False,是否为分段型
pieces:
[
{"min": 1500}, // 不指定 max,表示 max 为无限大(Infinity)。
{"min": 900, "max": 1500},
{"min": 310, "max": 1000},
{"min": 200, "max": 300},
{"min": 10, "max": 200, "label": '10 到 200(自定义label)'},
{"value": 123, "label": '123(自定义特殊颜色)', "color": 'grey'}, //表示 value 等于 123 的情况
{"max": 5} // 不指定 min,表示 min 为无限大(-Infinity)。
]

"""
map.set_global_opts(
visualmap_opts=options.VisualMapOpts(
is_show=True, is_piecewise=True,
pieces=[
{"min": 1, "max": 9, "label": "1-9人", "clor": "#CCFFFF"},
{"min": 10, "max": 99, "label": "10-99人", "clor": "#FFFF99"},
{"min": 100, "max": 499, "label": "100-499人", "clor": "#FF9966"},
{"min": 500, "max": 999, "label": "500-999人", "clor": "#CC666"},
{"min": 1000, "label": "1000人以上", "clor": "#990033"}
]
)
)
# 生成地图
map.render("map_test.html")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值