自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

關(guān)于Python可視化Dash工具—散點(diǎn)地圖、熱力地圖、線形地圖

開發(fā) 前端
好不容易實(shí)現(xiàn)了choropleth_mapbox地圖,也順道把散點(diǎn)地圖、熱力地圖、線形地圖處理掉吧,做到有始有終,再邁向新的領(lǐng)域.

?[[388264]]?

好不容易實(shí)現(xiàn)了choropleth_mapbox地圖,也順道把散點(diǎn)地圖、熱力地圖、線形地圖處理掉吧,做到有始有終,再邁向新的領(lǐng)域;從微信公眾號(hào)里拿到了按分省統(tǒng)計(jì)的用戶數(shù)據(jù),又拿到了各地市數(shù)據(jù),通過這兩種數(shù)據(jù)分別實(shí)現(xiàn)choropleth_mapbox、scatter_mapbox、density_mapbox,至于line_mapbox構(gòu)造數(shù)據(jù)過于麻煩,直接拷貝了官網(wǎng)上的案例。

基于分省統(tǒng)計(jì)的用戶數(shù)據(jù),通過choropleth_mapbox進(jìn)行行政區(qū)域的數(shù)據(jù)展示。

import json
import pandas as pd
import plotly.express as px
# 中國(guó)地圖
with open('china_geo.json') as response:
counties = json.load(response)

df = pd.read_csv("gongzhonghaopro.csv",encoding="utf-8",
dtype={"areacode": str})

fig = px.choropleth_mapbox(df, geojson=counties, featureidkey="properties.adcode",locations='areacode', color='total',
#color_continuous_scale="Viridis",
range_color=(0, 320),
color_continuous_scale='Reds',
zoom=3, center={"lat": 37.4189, "lon": 116.4219},
mapbox_style='carto-positron')

fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.show()

??

 

基于分地市統(tǒng)計(jì)的用戶數(shù)據(jù),通過scatter_mapbox進(jìn)行各城市的數(shù)據(jù)展示。這里面不同的地方是直接采用mapbox的地圖,而且申請(qǐng)了一個(gè)tokenkey,此外數(shù)據(jù)的構(gòu)成方面,需要附上各區(qū)域的經(jīng)度、維度、展示數(shù)據(jù)等信息。

all_data = pd.read_csv("gongzhonghao.csv",encoding="utf-8")
token = 'pk.eyJ1Ijoiam9obndhbmcyMDIxIiwiYSI6ImNrbWNheTJ1NzA4cWQyb21uZHYycTgzMGQifQ.Tyk26CpuPLPi3bpw05yM_A'
fig = px.scatter_mapbox(all_data, lat="langitude", lon="latitude", hover_name="city", hover_data=["city", "total"],
color="total",
size="total",
#color_continuous_scale=px.colors.sequential.matter,
size_max=30,
color_continuous_scale="Reds",
zoom=5, height=1000)

fig.update_layout(mapbox = {'accesstoken': token, #需要到官網(wǎng)注冊(cè)一個(gè)token
'center': {'lon': 106.573, 'lat': 30.66342}, #指定的地圖中心
'zoom': 3,
'style': 'basic', #顯示的地圖類型,有遙感地圖,街道地圖等類型
},
margin = {'l': 0, 'r': 0, 't': 0, 'b': 0})
fig.show()

 

基于分地市統(tǒng)計(jì)的用戶數(shù)據(jù),通過density_mapbox進(jìn)行各城市的數(shù)據(jù)展示。熱力圖相對(duì)來說呈現(xiàn)效果要好于scatter_mapbox,不過這里面關(guān)于range_color的設(shè)置一直沒想明白該如何正確處理。

all_data = pd.read_csv("gongzhonghao.csv",encoding="utf-8")
print(all_data)
fig = px.density_mapbox(all_data, lat='langitude', lon='latitude', z='total', radius=20,
color_continuous_scale=px.colors.diverging.RdYlGn[::-1],
center={"lat": 37.4189, "lon": 116.4219}, zoom=3,
range_color =(0,15),
mapbox_style="stamen-terrain")
fig.show()

??

 

基于官方案例的line_geo地圖展示。

??

 

下一步該探索一下dash_core_components 、dash_html_components 、idash_bootstrap_components組件了,最終的目標(biāo)是實(shí)現(xiàn)可視化大屏,還有很長(zhǎng)的路要走。

 

責(zé)任編輯:武曉燕 來源: python與大數(shù)據(jù)分析
相關(guān)推薦

2021-03-17 08:07:56

Python可視化工具

2020-03-11 14:39:26

數(shù)據(jù)可視化地圖可視化地理信息

2021-02-21 08:11:46

PythonDash工具

2014-01-17 10:36:39

2022-03-01 10:29:44

Kubernetes容器

2017-09-05 08:35:09

Python可視化地圖

2017-09-01 19:49:50

Python工具地圖

2015-10-29 09:36:48

2014-06-20 15:00:57

數(shù)據(jù)可視化

2023-02-07 11:44:02

2016-12-09 13:34:59

Maptrix數(shù)據(jù)可視化

2013-10-22 10:37:47

谷歌數(shù)據(jù)可視化

2020-04-15 10:34:05

數(shù)據(jù)Excel地圖

2020-12-29 08:04:16

可視化地圖組件日歷組件

2016-10-21 11:00:51

WOT技術(shù)

2021-06-15 14:33:00

高德百度騰訊

2013-05-16 14:31:49

GoogleGoogle Maps

2011-05-07 09:21:47

必應(yīng)地圖iOS谷歌地圖

2020-02-21 16:51:58

前端可視化傳染病

2020-07-06 14:50:36

地圖可視化Java
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)