Change color /width bar in function of the value of the x-axes

I want to make a bar graph showing first the result of the past three years, then the months of the current year.
Is it possible to change/width the colour of the bar when the x-axis value is in a year format?

import pandas as pd
import plotly.express as px
dates = [β€˜2020’, β€˜2021’, β€˜2022’, β€˜2023-01’,β€˜2023-02’]
amounts = [1000, 950, 1150, 80,8]
df = pd.DataFrame({β€˜Date’: dates, β€˜Amount’: amounts})
fig = px.bar(df, x=df.Date, y=[β€˜Amount’],title=β€œβ€,barmode=β€˜group’)
fig.show()
image

You could add a column to your DataFrame:

import pandas as pd
import plotly.express as px
dates = ['2020', '2021', '2022', '2023-01','2023-02']
amounts = [1000, 950, 1150, 80,8]

df = pd.DataFrame({'Date': dates, 'Amount': amounts})
df['color']=['past', 'past', 'past', 'now', 'now']

fig = px.bar(df, x=df.Date, y=['Amount'],barmode='group', color='color')
fig.show()

creates:
newplot (49)