So I have a Time-Series plot, but the problem with it is that the x labels are one over the other, and I'm wondering how to correct it?

Here's the code:

def time_series(start, end):
    time_series_df = Res[['Timestamp', 'Ammonia']][(Res['Timestamp'] >= start) & (Res['Timestamp'] <= end)]
    x = time_series_df.Timestamp
    y = time_series_df.Ammonia
    plt.ylabel('Ammonia Value')
    plt.title('Ammonia Time Series')

And when I display it:

time_series('2013-11-01 00:00:00','2013-12-31 23:00:00')

Here's what I get:

enter image description here

1 Answers

Alessandro Peca On Best Solutions

As I suggested in a comment on your post, you could rotate the labels with:

import matplotlib.pyplot as plt
import random

x = random.sample(range(1, 10000), 100)
y = random.sample(range(1, 10000), 100)
plt.plot(x, y, 'ro')
plt.xticks(rotation = 40) # 40 is the rotation angle

enter image description here

As described on the matplotlib references.