from pyecharts.charts import Map from pyecharts import options as opts from pyecharts.globals import ThemeType data = [ ('山东省',99), ('上海市',199), ('湖南省',299), ('台湾省',399), ('广东省',499) ] map = ( Map(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) .add("测试地图", data, maptype="china") .set_global_opts( visualmap_opts=opts.VisualMapOpts( is_show=True, is_piecewise=True, pieces=[ {"min": 1, "max": 9, "label": "1-9", "color": "#CCFFFF"}, {"min": 10, "max": 99, "label": "10-99", "color": "#FF6666"}, {"min": 100, "max": 500, "label": "100-500", "color": "#990033"}, ] ) ) ) map.render("d.html")
上述Python代码执行成功后,打开d.html文件即可正常显示。
标签:pyecharts,渲染,color,max,地图,label,import,opts From: https://www.cnblogs.com/zhzhang/p/18153845