【发布时间】:2022-01-10 20:19:21
【问题描述】:
有没有办法创建额外的等值线(最好是 Mapbox 等值线,但我会满足于 Plotly 的标准等值线函数)地图并将它们分层在基本等值线之上,以便我可以轻松地显示与阿拉斯加和夏威夷相关的数据美国大陆?
不要相信我现有的代码一定有用,但这是我构建基本地图的方式(删除了我的自定义样式,以便任何人都应该能够生成)。
fig = px.choropleth_mapbox(
df_mar,
geojson=puma,
locations="stpuma",
color="inter_pct",
range_color=(0,25),
color_continuous_scale="Viridis",
labels={"inter_pct": "Marriage (%)"},
center={"lat": 37.0902, "lon": -95.7129},
zoom=4.2,
opacity=1.0,
mapbox_style="white-bg"
)
fig.update_layout(
coloraxis_colorbar=dict(
bgcolor="rgba(22,33,49,1)",
title="Marriage,<br>Percent Share",
titlefont=dict(
color="rgba(255,255,255,1)"
),
tickfont=dict(
color="rgba(255,255,255,1)"
),
),
margin=dict(
l=50,
r=50,
b=50,
t=50,
pad=4
),
paper_bgcolor = "rgba(8,18,23,1)",
plot_bgcolor = "rgba(8,18,23,1)",
showlegend = True,
annotations = [
dict(
x=-0.025,
y=-0.04,
xref='paper',
yref='paper',
text='Source: Census ACS 5 2015-2019',
showarrow = False,
font=dict(
color="rgba(255,255,255,1)"
),
bgcolor="rgba(8,18,23,1)",
)
]
)
fig.update_traces(
marker_line_width=0,
below="waterway"
)
fig.show(width=1920, height=1080)
【问题讨论】:
标签: python plotly mapbox plotly-python