有没有办法始终在 plotly scattermapbox 中显示所有标记,而不管手动缩放?

Is there a way to always show all markers in a plotly scattermapbox, regardless of manual zooming?

我正在尝试根据数据框生成几张具有不同内容的地图。 到目前为止,我已经设法在交互式地图上显示我需要的信息。 但是,由于我需要将生成的地图作为图形包含在报告中,因此我需要找到一种方法来显示图形中的所有标记。问题是:有些标记仅在我手动放大该区域时显示。 有没有办法让标记始终可见?

代码如下:

import plotly.graph_objects as go

token = open("token.mapbox_token").read() # you need your own token

df_select = df_map.loc[df_map['Budget'] == 0.9]

fig= go.Figure(go.Scattermapbox(lat=df_select.Latitude, lon=df_select.Longitude,
                       mode='markers', marker=go.scattermapbox.Marker(
                          size=df_select.Warehouse_Size*5, color = df_select.Warehouse_Size, 
                          colorscale = ['white','red','orange','green','blue','purple'], 
                          showscale = False)))

fig = fig.add_trace(go.Choroplethmapbox(geojson=br_geo, locations=df_select.State, 
                           featureidkey="properties.UF_05", 
                           z=df_select.Top10,
                           colorscale=["white","pink"], showscale=False,
                           zmin = 0,
                           zmax=1,
                        marker_opacity=0.5, marker_line_width=1
                          ))

df_prio = df_select.loc[df_select['Prioritisated'] == 1]

fig= fig.add_trace(go.Scattermapbox(lat=df_prio.Latitude, lon=df_prio.Longitude+1, 
                       mode='markers', 
                       marker=go.scattermapbox.Marker(symbol = "campsite", size = 10)))

fig.update_layout(height=850,width = 870,
                  mapbox_style = "mapbox://styles/rafaelaveloli/ckollp2dg21dd19pmgm3vyebu",  
                  mapbox_zoom=3.4, mapbox_center = {"lat": -14.5 ,"lon": -52}, 
                  mapbox_accesstoken = token, showlegend= False)

fig.show()

这是我得到的结果:

这是只有在放大时才可见的隐藏标记之一:

如何在不更改图缩放和尺寸的情况下使其在第一个图中可见?

allowoverlap=True 传递给 go.scattermapbox.Marker() 似乎可以解决问题 (link to relevant docs)。