Plotly error with dropdown menu to display all values

I have a dataframe with total doses of the Covid-19 vaccine, with the name of the manufacturer and the location of the application. I’m trying to make a plot in Plotly with a dropdown menu where you can select the locale. But in my chart only the bars of a vaccine manufacturer appear, I want them all to appear. I made the chart without the dropdown and it worked, but I can’t do the same on the chart with the dropdown.

sigla_uf    nome_fabricante_vacina  dose_vacina data_aplicacao_vacina   total_doses
26668   SE  Pfizer  Reforço 2022-01-14  1140
26231   SE  Pfizer  1ª Dose 2022-01-14  27
18450   PE  Pfizer  Dose Adicional  2022-01-14  113
11495   MA  Janssen Reforço 2022-01-14  55
8969    CE  Pfizer  2ª Dose 2022-01-14  96

This is the code:

first_title = dfs1[0][0]
traces = []
buttons = []
for i,d in enumerate(dfs1):
    visible = [False] * len(dfs1)
    visible[i] = True
    name = d[0]
    #display(d[1])
    traces.append(
        px.histogram(d[1].query('dose_vacina == "2ª Dose"'),
                               x = "data_aplicacao_vacina", y = "total_doses",
                               color = "nome_fabricante_vacina",
                               color_discrete_map={"AstraZeneca": "#00CC96",
                                                   "Coronavac": "#EF553B",
                                                   "Pfizer": "#AB63FA",
                                                   "Janssen": "#F9C023"},
                               nbins=52, hover_name="nome_fabricante_vacina",
                               hover_data=["nome_fabricante_vacina"]
                              ).update_traces(visible=True if i==0 else False).data[0])
    
    buttons.append(dict(label=name,
                        method="update",
                        args=[{"visible":visible},
                              {"title":f"{name}"}]))

updatemenus = [{'active':0, "buttons":buttons}]

fig = go.Figure(data=traces,
                 layout=dict(updatemenus=updatemenus))
fig.update_layout(title=first_title, title_x=0.5)
fig.show()

Resultt:

Hi,

After a quick glance, I believe the error is related to the visible array length. Each color group (manufacturer) will be a trace, therefore your array should have 4 * len(dfs1) elements (if I understood correctly that dfs1 has one element per state).

Hope this helps!