Pyecharts描画地図(世界地図、都市地図、熱力図)
19963 ワード
一.pyechart世界地図(都市地図、熱力図)を描く
1.1 pyechart世界地図を描く
1.2 pyechart都市地図を描く
1.3 pyecharts熱力図を描く
1.1 pyechart世界地図を描く
from pyecharts import options as opts
from pyecharts.charts import Map
from pyecharts.faker import Faker
import os
#
value = [95.1, 23.2, 43.3, 66.4, 88.5]
attr = ["China", "Canada", "Brazil", "Russia", "United States"]
data = []
for index in range(len(attr)):
city_ionfo=[attr[index],value[index]]
data.append(city_ionfo)
c = (
Map()
.add(" ",data, "world")
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
title_opts=opts.TitleOpts(title=" "),
visualmap_opts=opts.VisualMapOpts(max_=200),
)
.render()
)
# html
os.system("render.html")
1.2 pyechart都市地図を描く
# _*_ coding: utf-8 _*_
# !/usr/bin/python
"""
Author:mym
Create Date: -11:28
User: EDZ
description:
"""
from pyecharts import options as opts
from pyecharts.charts import Map
from pyecharts.faker import Faker
import os
class CityLocate:
def __init__(self):
self.province_distribution = \
{
' ': 45.23, ' ': 37.56, ' ': 21, ' ': 12, ' ': 6, ' ': 20, ' ': 10, ' ': 16, ' ': 9,
' ': 13, ' ': 2, ' ': 22, ' ': 8, ' ': 11, ' ': 1, ' ': 11, ' ': 7, ' ': 3,
' ': 3, ' ': 6, ' ': 2, ' ': 3, ' ': 12, ' ': 11, ' ': 4, ' ': 1, ' , ': 1,
' ': 1, ' ': 1
}
self.provinces = list(self.province_distribution.keys())
self.city_numbers = list(self.province_distribution.values())
def render_data(self):
c = (
Map().add("", [list(z) for z in zip(self.provinces, self.city_numbers)], "china")
.set_global_opts(title_opts=opts.TitleOpts(title=" ")).render()
)
os.system('render.html')
if __name__ == '__main__':
# CityLocate().render_data()
1.3 pyecharts熱力図を描く
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.faker import Faker
from pyecharts.globals import ChartType
import os
#
keys = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
values = [4.07, 1.85, 4.38, 2.21, 3.53, 4.37, 1.38, 4.29, 4.1, 1.31, 3.92, 4.47, 2.40, 3.60, 1.2, 3.7]
c = (
Geo()
.add_schema(maptype="china")
.add(
" ",
[list(z) for z in zip(keys, values)],
type_=ChartType.EFFECT_SCATTER,
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(title_opts=opts.TitleOpts(title=" "))
.render()
)
# html
os.system("render.html")