0
votes

Suppose i have a data frame "ltyc" of size (12,2) that looks like the following and I'm trying to plot a line plot using matplotlib and I need the x ticks to show the months only that are shown in the column of "time" below:

         time   LT Mean
0  2020-01-01  7.411365
1  2020-02-01  7.193070
2  2020-03-01  7.397183
3  2020-04-01  7.684527
4  2020-05-01  7.670577
5  2020-06-01  7.348572
6  2020-07-01  6.898480
7  2020-08-01  6.852384
8  2020-09-01  7.250651
9  2020-10-01  7.681693
10 2020-11-01  7.587329
11 2020-12-01  7.444730

I've tried this approach but nothing plots just an empty (white) plot:

fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(ltyc.time, 
    ltyc.iloc[:,1])

I'm trying to plot the column "LT Mean" with the dates on the x axis as months like (Jan, Feb, Mar,..Dec). Thank you for any help here.

1

1 Answers

2
votes

Did you try:

df.plot(x='time')

Output:

enter image description here