I am working on some data that looks something like below:
Date | Time | Delay | Day |
---|---|---|---|
2018-01-01 | 00:29 | 10 | Monday |
2018-01-01 | 01:22 | 10 | Monday |
2018-01-01 | 01:39 | 10 | Monday |
2018-01-01 | 02:09 | 10 | Monday |
2018-01-01 | 02:58 | 10 | Monday |
2018-01-02 | 03:19 | 10 | Tuesday |
2018-01-02 | 03:29 | 10 | Tuesday |
2018-01-02 | 04:50 | 10 | Tuesday |
2018-01-03 | 04:59 | 10 | Wednesday |
I am trying to plot a lineplot with x-axis being the Time column. Currently, I have this code:
def plot_lineplot(df_temp):
plt.figure(figsize=(20,5))
ax = sns.lineplot(data=df_date, x='Time', y="Min Delay", hue="Day")
ax.set_xlim(df_date["Time"].min(), df_date["Time"].max())
for item in ax.get_xticklabels():
item.set_rotation(90)
This code produces the following result:
When the data increase, x-axis jumbles up as below:
I want to have custom x-labels as Time, e.g., 00:00, 04:00, 08:00, 12:00, 16:00, 20:00 and 23:59 so that x-axis labels dont change even if data increases or decreases.