|
語法 |
說明 |
| from pyecharts.charts import Geo | 導(dǎo)入地圖庫 |
| Geo() | Pyecharts地理圖表繪制 |
| .add_map(maptype=“china“) | 地圖類型 |
| .add() | 添加數(shù)據(jù) |
| .set_global_opts() | 設(shè)置全局配置項(xiàng) |
實(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()
運(yùn)行結(jié)果:

實(shí)例代碼:
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='中國地圖(特效散點(diǎn)圖)'),
visualmap_opts=opts.VisualMapOpts(
is_piecewise=True
)
)
).render()
運(yùn)行結(jié)果:

實(shí)例代碼:
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è)置(點(diǎn))
.add('', data_pair=start_end, type_=ChartType.LINES, # 設(shè)置線
effect_opts=opts.EffectOpts(symbol=SymbolType.ARROW,color='blue', symbol_size=7)) # 流動(dòng)箭頭繪制
).render()
運(yùn)行結(jié)果:

實(shí)例代碼:
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()
運(yùn)行結(jié)果:

實(shí)例代碼:
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()
運(yùn)行結(jié)果:

到此這篇關(guān)于Python數(shù)據(jù)可視化之基于pyecharts實(shí)現(xiàn)的地理圖表的繪制的文章就介紹到這了,更多相關(guān)pyecharts繪制地理圖表內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:迪慶 揚(yáng)州 楊凌 聊城 南寧 牡丹江 撫州 六盤水
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Python數(shù)據(jù)可視化之基于pyecharts實(shí)現(xiàn)的地理圖表的繪制》,本文關(guān)鍵詞 Python,數(shù)據(jù),可視化,之,基于,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。