python-如何在Python / Plotly Choropleth图中放大地理地图?

问题描述

我正在与Plotly制作一个choropleth情节。但是,地理地图看起来很小。

like that:

我的代码在这里:

fig = px.choropleth(df,geojson=geojson,locations="Capitalize",featureidkey="properties.name",color="Scale",hover_name='Capitalize',hover_data=['Quantity'],animation_frame="Period",projection="mercator",)

fig.update_geos(fitbounds="locations",visible=False)
fig.update_layout(title_text = 'Product A',autosize=True,hovermode='closest',title_x = 0.5,margin={"r":0,"t":100,"l":0,"b":0},geo=dict(showframe = False,showcoastlines = False))

width和height属性不能完全满足我的要求。我只想放大地理地图。我该怎么做呢?

解决方法

查看 Plotly's website 并向下滚动到 fitbounds 部分。

我相信您的问题可能是代码 fig.update_geos(fitbounds="locations",visible=False)

您需要将“位置”部分更改为其他内容,例如“geojson”或“False”。

希望这有效!

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...