How to show data by day in a Plotly chart
Solution 1:
Solution 1
You can manually set the width of the bins:
grafico.update_traces(xbins_size=1)
Solution 2
You can pass a parameter called nbins. If you set nbins to the number of days, you'll get one bar per day. You could try
days = df['data_aplicacao_vacina'].unique().size
grafico = px.histogram(df.query('dose_vacina == "1ª Dose"'), x = "data_aplicacao_vacina", y = "doses_totais", color = "nome_fabricante_vacina",
color_discrete_map={
"AstraZeneca": "#00CC96",
"Coronavac": "#EF553B",
"Pfizer": "#AB63FA"},
title="Aplicação diária da 1ª dose, em Alagoas",
hover_name="nome_fabricante_vacina", hover_data=["nome_fabricante_vacina"],
nbins=days)
grafico.show()
See #Choosing the number of bins for reference.