You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Plotly choropleth地图中的OpenStreetMap版权标识?

移除Plotly Choropleth Mapbox底部的OpenStreetMap版权水印

要解决这个问题,直接通过Plotly的布局配置关闭Mapbox的版权标注控件即可,具体操作如下:

解决方案:修改布局参数关闭版权控件

在创建完fig对象后,添加update_layout配置,将mapbox_attribution_control设置为False,这样不管是交互式展示还是导出静态图片,底部的版权标注都会被移除。

修改后的完整代码:

import plotly.express as px
import geopandas as gpd

df = px.data.election()
geo_df = gpd.GeoDataFrame.from_features(
    px.data.election_geojson()["features"]
).merge(df, on="district").set_index("district")

fig = px.choropleth_mapbox(geo_df,
                           geojson=geo_df.geometry,
                           locations=geo_df.index,
                           color="Joly",
                           center={"lat": 45.5517, "lon": -73.7073},
                           mapbox_style="open-street-map",
                           zoom=8.5)

# 关键:关闭版权标注控件
fig.update_layout(mapbox_attribution_control=False)

fig.show()
fig.write_image('image.jpeg')

补充说明

OpenStreetMap的版权要求中,若你已经在论文正文里专门致谢了贡献者,关闭图片上的标注是符合规范的。如果后续需要保留简化标注,也可以自定义标注内容,比如:

fig.update_layout(mapbox_attribution="© OpenStreetMap")

内容的提问来源于stack exchange,提问作者César Leblanc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 04:12:35