Pyecharts 지리 데이터 시각 화 방법
                                            
 10846 단어  Pyecharts지리 데이터 시각 화
                    
 
 1.Pyecharts 소개 및 설치
1.프로필
Echarts 는 바 이 두 에서 개 원 된 데이터 시각 화 로 좋 은 상호작용 성,정교 한 도표 디자인 으로 많은 개발 자 들 의 인정 을 받 았 다.파 이 썬 은 표 현 력 이 풍부 한 언어 로 데이터 처리 에 적합 하 다.데이터 분석 이 데이터 시각 화 를 만 났 을 때 pyecharts 가 탄생 했다.
4.567917.상세 한 문서 와 예 를 들 어 개발 자 들 이 더 빨리 시작 할 수 있 도록 도와 주 는 프로젝트4.567917.400+지도 파일 에 달 하고 원생 바 이 두 지 도 를 지원 하여 지리 데이터 시각 화 에 강력 한 지 지 를 제공 합 니 다pyecharts 버 전 v0.5.x 와 v1 이 호 환 되 지 않 고 v1 은 새로운 버 전 이 며 문법 도 많이 다르다.
2.설치
pyecharts 설치
pip install pyecharts -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
import pyecharts
print(pyecharts.__version__)     #     pyecharts  
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-countries-pypkg  		#       
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-china-provinces-pypkg  #       
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-china-cities-pypkg   #       
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple echarts-china-counties-pypkg  #        
1.세계 지도
Starbucks.csv 의 데 이 터 를 이용 하여 각 국가(Country)에 대응 하 는 매장 수 를 계산 한 다음 에 세계 지 도 를 이용 하여 스타 벅 스 매장 의 전 세계 수량 분 포 를 시각 적 으로 보 여 줍 니 다.
# -*- coding: UTF-8 -*-
"""
@File  :demo1.py
@Author :   
@CSDN  :https://yetingyun.blog.csdn.net/
"""
import pandas as pd
from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.globals import ThemeType, CurrentConfig
CurrentConfig.ONLINE_HOST = 'D:/python/pyecharts-assets-master/assets/'
# pandas  csv      
df = pd.read_csv("Starbucks.csv")['Country']
#              
data = df.value_counts()
datas = [(i, int(j)) for i, j in zip(data.index, data.values)]
#      Map  
map_ = Map(init_opts=opts.InitOpts(theme=ThemeType.PURPLE_PASSION))
#     
map_.add("    ", data_pair=datas, maptype="world")
map_.set_series_opts(label_opts=opts.LabelOpts(is_show=False))  #    label
map_.set_global_opts(
   title_opts=opts.TitleOpts(title="            ", pos_left='40%', pos_top='10'),  #   title  
   legend_opts=opts.LegendOpts(is_show=False),
   visualmap_opts=opts.VisualMapOpts(max_=13608, min_=1, is_piecewise=True,
   pieces=[{"max": 9, "min": 1, "label": "1-9", "color": "#00FFFF"},    #             
     {"max": 99, "min": 10, "label": "10-99", "color": "#A52A2A"},
     {"max": 499, "min": 100, "label": "100-499", "color": "#0000FF	"},
     {"max": 999, "min": 500, "label": "500-999", "color": "#FF00FF"},
     {"max": 2000, "min": 1000, "label": "1000-2000", "color": "#228B22"},
     {"max": 3000, "min": 2000, "label": "2000-3000", "color": "#FF0000"},
     {"max": 20000, "min": 10000, "label": ">=10000", "color": "#FFD700"}
       ])
   )
#       
map_.render('           .html')
 
 2.국가 지도
잔물결 산포도
china.csv 의 데 이 터 를 이용 하여 먼저 각 도시(City)에 대응 하 는 가게 의 수량 을 계산 한 다음 에 pyecharts 가방 안의 Geo 모듈 로 스타 벅 스 가게 가 중국 각 도시 에 분포 하 는 파문 산 점 지 도 를 그립 니 다.
import pandas as pd
from pyecharts.globals import ThemeType, CurrentConfig, GeoType
from pyecharts import options as opts
from pyecharts.charts import Geo
CurrentConfig.ONLINE_HOST = 'D:/python/pyecharts-assets-master/assets/'
# pandas  csv    
df = pd.read_csv("china.csv")['City']
data = df.value_counts()
datas = [(i, int(j)) for i, j in zip(data.index, data.values)]
print(datas)
geo = Geo(init_opts=opts.InitOpts(width='1000px', height='600px', theme=ThemeType.DARK))
geo.add_schema(maptype='china', label_opts=opts.LabelOpts(is_show=True))  #   label   
geo.add('    ', data_pair=datas, type_=GeoType.EFFECT_SCATTER, symbol_size=8)
geo.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
geo.set_global_opts(title_opts=opts.TitleOpts(title='           '),
          visualmap_opts=opts.VisualMapOpts(max_=550, is_piecewise=True,
          pieces=[{"max": 50, "min": 0, "label": "0-50", "color": "#708090"},    #              
               {"max": 100, "min": 51, "label": "51-100", "color": "#00FFFF"},
               {"max": 200, "min": 101, "label": "101-200", "color": "#00008B"},
               {"max": 300, "min": 201, "label": "201-300", "color": "#8B008B"},
               {"max": 600, "min": 500, "label": "500-600", "color": "#FF0000"},
                 ])
          )
geo.render("           .html")
 
 동적 궤적 도
# -*- coding: UTF-8 -*-
"""
@File  :demo3.py
@Author :   
@CSDN  :https://yetingyun.blog.csdn.net/
"""
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType, CurrentConfig, ThemeType
CurrentConfig.ONLINE_HOST = 'D:/python/pyecharts-assets-master/assets/'
#     
c = (
  Geo()
  .add_schema(
    maptype="china",
    itemstyle_opts=opts.ItemStyleOpts(color="#323c48", border_color="#111"),
    label_opts=opts.LabelOpts(is_show=True)
  )
  .add(
    "",
    [("  ", 55), ("  ", 66), ("  ", 77), ("  ", 88), ('  ', 100), ('  ', 80)],
    type_=ChartType.EFFECT_SCATTER,
    color="white",
  )
  .add(
    "",
    [("  ", "  "), ("  ", "  "), ("  ", "  "), ("  ", "  "),
     ('  ', '  '), ('  ', '  '), ('  ', '  '), ('  ', '  ')
     ],
    type_=ChartType.LINES,
    effect_opts=opts.EffectOpts(
      symbol=SymbolType.ARROW, symbol_size=6, color="blue" #      
    ),
    linestyle_opts=opts.LineStyleOpts(curve=0.2), #       
  )
  .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
  .set_global_opts(title_opts=opts.TitleOpts(title="     "))
  .render("geo_lines_background.html")
)
 
 3.성시 지도
열 그래프
# -*- coding: UTF-8 -*-
"""
@File  :demo4.py
@Author :   
@CSDN  :https://yetingyun.blog.csdn.net/
"""
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.faker import Faker
from pyecharts.globals import GeoType, CurrentConfig
CurrentConfig.ONLINE_HOST = 'D:/python/pyecharts-assets-master/assets/'
c = (
  Geo()
  .add_schema(maptype="  ", label_opts=opts.LabelOpts(is_show=True))
  .add(
    "   ",
    [list(z) for z in zip(Faker.guangdong_city, Faker.values())],
    type_=GeoType.HEATMAP,
  )
  .set_series_opts(label_opts=opts.LabelOpts(is_show=True))
  .set_global_opts(
    visualmap_opts=opts.VisualMapOpts(), title_opts=opts.TitleOpts(title="Geo-    ")
  )
  .render("geo_guangdong.html")
)
 
 지도 에 위도 데 이 터 를 대량으로 추가 합 니 다.
데 이 터 는 미 단 망 청 두 지역 호텔 정보 에서 기원 되 었 고 그 중에서 호텔 의 경위도 데 이 터 를 이용 하여 지도 에 대량으로 추가 하여 시각 화 되 었 다.
# -*- coding: UTF-8 -*-
"""
@File  :demo5.py
@Author :   
@CSDN  :https://yetingyun.blog.csdn.net/
"""
import pandas as pd   
from pyecharts.charts import Geo  
from pyecharts import options as opts  
from pyecharts.globals import GeoType, CurrentConfig, ThemeType
CurrentConfig.ONLINE_HOST = 'D:/python/pyecharts-assets-master/assets/'
#   Excel              
df = pd.read_excel("hotel.xlsx")
#            
geo_sight_coord = {df.iloc[i]['    ']: [df.iloc[i]['  '], df.iloc[i]['  ']] for i in range(len(df))}
data = [(df['    '][j], f"{int(df['   '][j])} (   )") for j in range(len(df))]
# print(data)
# print(geo_sight_coord)
#    Geo         
g = Geo(init_opts=opts.InitOpts(theme=ThemeType.PURPLE_PASSION, width="1000px", height="600px"))
g.add_schema(maptype="  ")
for k, v in list(geo_sight_coord.items()):
  #     、     
  g.add_coordinate(k, v[0], v[1])
#        
g.add("", data_pair=data, type_=GeoType.EFFECT_SCATTER, symbol_size=6)
g.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
g.set_global_opts(title_opts=opts.TitleOpts(title="  -      "))
g.render("      .html")
 
 Pyecharts 지리 데이터 시각 화 방법 을 알 고 있 는 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 Pyecharts 지리 데이터 시각 화 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 조회 하 시기 바 랍 니 다.앞으로 많은 응원 바 랍 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Pyecharts 에서 Geo 함수 가 자주 사용 하 는 매개 변수의 용법 설명새 버 전 Pyecharts 의 지리 도표 Geo 는 비교적 큰 변화 가 있 었 다.전체적인 가장 직관 적 인 업데이트 느낌 은 새로운 라 이브 러 리 가 예전 처럼 번 거 롭 지 않 고 응용 하기에 더욱 간단 하고...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.