Hi everyone,
I’m using px.scatter_mapbox to plot some geographical points.
I want to show both the simple scatter where every point has the same size and also the updated plot where the size of each marker is proportional to the corresponding value assigned to that point in the geodataframe (gdf
).
My code looks like this:
fig = px.scatter_mapbox(gdf,
lat='lat',
lon='lon',
size = None,
color = 'cluster',
hover_data=['date']
)
fig.update_layout(
updatemenus=[
dict(
type='buttons',
direction = 'right',
buttons=list([
dict(
args=['size', None],
label='Sample Location',
method='restyle'
),
dict(
args=['size', 'value_column'],
label='Value-related Size',
method='restyle'
)
]),
pad={'l':10,'t':10},
showactive=True,
x=0.11,
xanchor="left",
y=1.2,
yanchor="top"
)
]
)
Unfortunately the buttons show up but they don’t do anything when clicked.
I believe that args=['size', value]
might be the problem here (where value is either None
or the value_column
).
The other possibility is that px.scatter_mapbox might work differently than plotly.graph_objects figures and thus require some special coding, but I haven’t found anything in particular to let me think this.
Also I’m following this reference (Custom buttons in Python)
Any help is appreciated