Mapbox 密度热图#
在使用 px.density_mapbox
时,数据帧的每一行都表示为具有给定影响半径的平滑点:
import pandas as pd
import plotly.express as px
from plotly import graph_objects as go
go.FigureWidget(); # 用于初始化
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')
fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
center=dict(lat=0, lon=180), zoom=0,
mapbox_style="stamen-terrain")
fig.show()
Stamen 地形基础地图(不需要标记):使用 plotly.graph_objects
的密度 mapbox#
fig = go.Figure(go.Densitymapbox(lat=df.Latitude, lon=df.Longitude, z=df.Magnitude,
radius=10))
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()