I think he want to show make and model as xaxis tick.
@Andrei: So I think you can make a new columns that merge 2 column make
and model
then use it to make your chart instead of update_traces
.
import pandas as pd
import plotly.express as px
data = {'Hom number':[51,38,53,56,54,52,42,50,55,51,38,53,44,56,54,52,42,50,55,51,38,53,44,56,54,52,42,50,55,51,38,53,44,56,54,52,42,50,55],
'make':['Aston Martin', 'Audi', 'BMW', 'Ferrari', 'Lamborghini', 'McLaren', 'Mercedes', 'Porsche', 'Porsche',
'Aston Martin', 'Audi', 'BMW', 'Ferrari', 'Ferrari','Lamborghini', 'McLaren', 'Mercedes', 'Porsche', 'Porsche',
'Aston Martin', 'Audi', 'BMW', 'Ferrari', 'Ferrari','Lamborghini', 'McLaren', 'Mercedes', 'Porsche', 'Porsche',
'Aston Martin', 'Audi', 'BMW', 'Ferrari', 'Ferrari','Lamborghini', 'McLaren', 'Mercedes', 'Porsche', 'Porsche'],
'model':['AMR GT3', 'R8LMS', 'M4 GT3', '296 GT3', 'Huracan GT3', '720GT3', 'AMG GT3', '911-991', '911-992',
'AMR GT3', 'R8LMS', 'M4 GT3', '488 GT3', '296 GT3', 'Huracan GT3', '720GT3', 'AMG GT3', '911-991', '911-992',
'AMR GT3', 'R8LMS', 'M4 GT3', '488 GT3', '296 GT3', 'Huracan GT3', '720GT3', 'AMG GT3', '911-991', '911-992',
'AMR GT3', 'R8LMS', 'M4 GT3', '488 GT3', '296 GT3', 'Huracan GT3', '720GT3', 'AMG GT3', '911-991', '911-992'],
'bop_date':['2023.04.13', '2023.04.13', '2023.04.13', '2023.04.13', '2023.04.13','2023.04.13', '2023.04.13', '2023.04.13', '2023.04.13',
'2023.04.19', '2023.04.19', '2023.04.19', '2023.04.19', '2023.04.19','2023.04.19', '2023.04.19', '2023.04.19', '2023.04.19', '2023.04.19',
'2023.04.22', '2023.04.22', '2023.04.22', '2023.04.22', '2023.04.22','2023.04.22', '2023.04.22', '2023.04.22', '2023.04.22', '2023.04.22',
'2023.04.23', '2023.04.23', '2023.04.23', '2023.04.23', '2023.04.23','2023.04.23', '2023.04.23', '2023.04.23', '2023.04.23', '2023.04.23'],
'bop_ballast':[25,55,50,45,0,50,60,50,40,
25,55,50,45,45,60,50,60,50,40,
15,65,40,35,25,50,35,75,45,30,
15,65,50,35,20,50,45,75,45,25]}
df = pd.DataFrame(data)
df['make_model'] = df['make'] + ' ' + df['model']
fig_bal = px.bar(df,x='make_model',y='bop_ballast',color='bop_date',barmode='group',template = "plotly_dark",text="bop_ballast")
fig_bal.show()