Python數(shù)據(jù)可視化之基于pyecharts實現(xiàn)的地理圖表的繪制
一、例子:百度遷徙
百度地圖春節(jié)人口遷徙大數(shù)據(jù)(簡稱百度遷徙),是百度在2014年春運期間推出的一項技術(shù)項目。百度遷徙利用大數(shù)據(jù),對其擁有的LBS(基于地理位置的服務(wù))大數(shù)據(jù)進行計算分析,采用的可視化呈現(xiàn)方式,動態(tài)、即時、直觀地展現(xiàn)中國春節(jié)前后人口大遷徙的軌跡與特征。
網(wǎng)址:https://qianxi.baidu.com/2021/

二、基礎(chǔ)語法介紹
|
語法 |
說明 |
| from pyecharts.charts import Geo | 導(dǎo)入地圖庫 |
| Geo() | Pyecharts地理圖表繪制 |
| .add_map(maptype=“china“) | 地圖類型 |
| .add() | 添加數(shù)據(jù) |
| .set_global_opts() | 設(shè)置全局配置項 |
三、中國地圖繪制
實例代碼:
from pyecharts.charts import Geo import pyecharts.options as opts from commons import Faker ( Geo() .add_schema(maptype='china') # 使用中國地圖的類型 .add(series_name='', data_pair=[(i, j) for i, j in zip(Faker.provinces, Faker.values())]) .set_global_opts( title_opts=opts.TitleOpts(title='中國地圖'), visualmap_opts=opts.VisualMapOpts( # is_piecewise=True# 非連續(xù)型顯示 ) ) ).render()
運行結(jié)果:

四、中國地圖(特效散點圖)
實例代碼:
from pyecharts.charts import Geo import pyecharts.options as opts from pyecharts.globals import ChartType from commons import Faker ( Geo() .add_schema(maptype='china') # 使用中國地圖的類型 .add(series_name='', data_pair=[(i, j) for i, j in zip(Faker.provinces, Faker.values())], type_=ChartType.EFFECT_SCATTER) .set_global_opts( title_opts=opts.TitleOpts(title='中國地圖(特效散點圖)'), visualmap_opts=opts.VisualMapOpts( is_piecewise=True ) ) ).render()
運行結(jié)果:

五、中國人口地理遷徙圖繪制
實例代碼:
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType
import pyecharts.options as opts
# 數(shù)據(jù)構(gòu)建(元組形式)
city_num = [('廣州', 105), ('成都', 70), ('北京', 99), ('西安', 80)]
start_end = [('廣州', '成都'), ('廣州', '北京'), ('廣州', '西安')]
(
Geo()
.add_schema(maptype='china', itemstyle_opts=opts.ItemStyleOpts(color='#323c48', border_color='#111'))# 地圖形式設(shè)置
.add('', data_pair=city_num, color='white') # 地圖數(shù)據(jù)顏色設(shè)置(點)
.add('', data_pair=start_end, type_=ChartType.LINES,# 設(shè)置線
effect_opts=opts.EffectOpts(symbol=SymbolType.ARROW,color='blue', symbol_size=7))# 流動箭頭繪制
).render()
運行結(jié)果:

六、熱力圖:廣東地圖熱力圖繪制1
實例代碼:
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType
c = (
Geo()
.add_schema(maptype="廣東", itemstyle_opts=opts.ItemStyleOpts(color="#323c48", border_color="#111"),)
.add("",[list(z) for z in zip(Faker.guangdong_city, Faker.values())],type_=ChartType.HEATMAP)
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(),
title_opts=opts.TitleOpts(title="廣東地圖熱力圖"),
)
)
c.render()
運行結(jié)果:

七、熱力圖:廣東地圖熱力圖繪制2
實例代碼:
from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.globals import ChartType
c = (
Map()
.add('', [list(z) for z in zip(Faker.guangdong_city, Faker.values())], "廣東")
.set_global_opts(
title_opts=opts.TitleOpts(title="Map-廣東地圖"),
visualmap_opts=opts.VisualMapOpts(),
)
)
c.render()
運行結(jié)果:

到此這篇關(guān)于Python數(shù)據(jù)可視化之基于pyecharts實現(xiàn)的地理圖表的繪制的文章就介紹到這了,更多相關(guān)pyecharts繪制地理圖表內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信