I am facing difficulties trying to customize the x-axis ticks labels. I am plotting a graph on Count of Laptops sold daily. What I want is the x-axis to show all the 7-days Day and corresponding count value including days where 0 laptops are sold. I would also like the x-axis(day) to be sorted in ascending order. How do I do that? Below is my code:
count = [5,1,12,3,4]
day = pd.Series(['3','2','4','5','7'], dtype="category")
df = pd.DataFrame({'day':day, 'count':count})
trace1 = go.Bar(x=df['day'], y=df['count'], name= 'Day', text=df['count'], textposition='auto', marker_color='rgb(55, 83, 109)')
data = [trace1]
layout = go.Layout(title='Laptops sold daily', xaxis=dict(title='Day'), yaxis=dict(title='Count of Laptops'), hovermode='closest')
fig = go.Figure(data=data, layout=layout)
pyo.iplot(fig)
Dataframe Output
Graph Output
Output Graph based on Accepted Solution:
question from:
https://stackoverflow.com/questions/65933037/how-to-customize-axis-ticks-label-on-x-or-y-axis-in-pandas 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…