I’ve got a pandas hist plot like shown below. As you can see the xticks are currently set to 0-6 (Sunday – Saturday). I’d like to replace the tick label to the actual days so the days are showing instead of numbers. 0 – Sunday 1 – Monday 2 – Tuesday 3 – Wednesday . .
JavaScript
x
5
1
ax_by_day = df['Day Of Week'].hist(bins=7, alpha=0.5, figsize=(10,6), edgecolor='black')
2
ax_by_day.set_xticks(list(range(0,7,1)))
3
ax_by_day.set_xlabel('Day')
4
ax_by_day.set_ylabel('No. of Processes Executed')
5
I believe there’s a way to map the xticks to new labels but surprisingly I’m unable to find details. Thanks in advance.
Advertisement
Answer
Using one of the many useful features of calendar
:
JavaScript
1
4
1
import calendar
2
days = calendar.day_name
3
ax_by_day.set_xticklabels(days[6:] + days[:6])
4