Hi All,
I had a question recently answered where I had to use buttons in an updatemenu to update the underlying dataframe behind a plotly figure here. I’m still working on a similar set-up, this time with a px.bar , and I’m failing to get the same code working
import plotly.express as px
df = px.data.gapminder()
dfstart = df[df['year'] == 1967]
bar = px.bar(
x = dfstart["continent"],
color= dfstart["country"],
y= dfstart["pop"]
#log_y = False
)
df67 = df[df['year'] == 1967]
yearbuttons = [
{'label': "67", 'method': 'update',
'args':
[{'x': [df67['continent']],
'y': [df67['pop']],
'color': [df67['country']]
},{'title': '1967'}]}
]
bar.update_layout(
updatemenus=[
dict(
type = "dropdown",
direction = "down",
buttons=yearbuttons,
x=1,
xanchor="left",
y=1.3,
yanchor="top",
active = 0
)
]
)
bar.show()
I’m expecting the update button to do nothing once selected ( except add a title), but it instead blows up the numbers to much larger than they should be. I’m planning to extend this example to have multiple buttons for different years/ point towards my own dataframe, but for now, I can’t understand what the issue is.
Any help would be greatly appreciated,
Thanks