I'm using a single dataframe merged from two source dataframes to plot a data series. Both plots work well, but I'm having trouble controlling the x-axis labels displayed in the line plot, even though the code I'm using for both plots is otherwise identical.
This code:
merged_data = pd.merge(newdata, newstuff, on='Date')
ax = merged_data.plot(kind='bar', figsize=(20, 7))
ax.set_xticklabels(merged_data.Date, rotation=45)
ax.set_ylabel('CPI vs. Wages and salaries - 12-month change')
ax.set_xlabel('Dates')
Produces this output:
But this code:
ax = merged_data.plot(kind='line', figsize=(20, 7))
ax.set_xticklabels(merged_data.Date, rotation=45)
ax.set_ylabel('CPI vs. Wages and salaries - 12-month change')
ax.set_xlabel('Dates')
gives me this output:
I certainly don't mind having fewer labels so they'll be easier to read, but the labels I'm getting on the line graph don't correspond to the actual data: the data covers 20 years (as you can see from the labels in the first graph), but the line-graph labels only cover the first two years.
From carefully visually scanning the graphs themselves, they both seem to be tracking the full data set.
Any idea what I'm missing?
Thanks,
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…