1. from pyecharts import options as opts
    2. from pyecharts.charts import Map
    3. from pyecharts.faker import Faker
    4. #定义数据
    5. provinces = Faker.provinces
    6. guangdong_city = Faker.guangdong_city
    7. values = Faker.values()
    8. country = Faker.country
    9. print(provinces)
    10. print(values)
    11. #Map方法制作全国地图
    12. c = (
    13. Map()
    14. #.add("商家A", [list(z) for z in zip(provinces, values)], "china",)
    15. .add("商家A", [list(z) for z in zip(guangdong_city, values)], "广东",)
    16. #.add("商家A", [list(z) for z in zip(country, values)], "world")
    17. # 设置全局项
    18. #.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) #不显示标签
    19. .set_global_opts(
    20. # 设置标题名称
    21. title_opts=opts.TitleOpts(
    22. title="Map-VisualMap(连续型)" ,
    23. subtitle="我是副标题-数据只是模拟",
    24. pos_left="center" # 设置标题居中
    25. ),
    26. # 设置图例配置项
    27. legend_opts=opts.LegendOpts(
    28. pos_right="right", # 设置为水平居左right
    29. pos_bottom="bottom" # 设置为垂直居下
    30. ),
    31. #visualmap_opts=opts.VisualMapOpts(max_=200),
    32. #visualmap_opts=opts.VisualMapOpts(max_=200, is_piecewise=True),
    33. )
    34. )
    35. c.render("map.html") # 生成名为map的本地html文件