I've plotted a line, and I wanted to show every month from the beginning of the data to the end. For that, I've tried to use the date column given in the dataset, but values overlapped. Then I've tried the following code:
rollingus = united_states['new_cases'].rolling(7).mean()
fig,ax = plt.subplots(figsize=(12,9))
plt.plot(rollingus,label='7 Days rolling average')
plt.plot(united_states['new_cases'],label=' Number of new cases each day')
plt.xlabel('Date')
plt.ylabel('Number of new cases')
plt.title('New cases In United States (Figure 1.1)')
ax.xaxis.set_major_locator(MultipleLocator(30))
ax.xaxis.set_minor_locator(MultipleLocator(7))
ax.set_xticklabels(['Dec','Jan','Feb 2020',' Mar',' Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan','Feb 2021','Mar','Apr'],minor=False)
plt.legend()
plt.show()
However, the dates are not exactly right. As shown in the figure I wanted them to start at the beginning of the y-values but it starts few values after that. Can anyone help me?