I have the following code:
import pandas as pd
from pandas import DataFrame as df
import matplotlib
from pandas_datareader import data as web
import matplotlib.pyplot as plt
import datetime
import warnings
warnings.filterwarnings("ignore")
from matplotlib import dates as mdates
start = datetime.date(2021,1,1)
end = datetime.date.today()
stock = 'fb'
data = web.DataReader(stock, 'yahoo', start, end)
data.index = pd.to_datetime(data.index, format ='%Y-%m-%d')
data = data[~data.index.duplicated(keep='first')]
data.reset_index()
data['month'] = data.index.month
data['week'] = data.index.week
data['day'] = data.index.day
data = data.reset_index()
del data['Date']
data.set_index('month',append=True,inplace=True)
data.set_index('week',append=True,inplace=True)
data.set_index('day',append=True,inplace=True)
fig, ax = plt.subplots(dpi=300, figsize =(15,4))
plt.plot(data.index.get_level_values(0), data['Close'])
locator = mdates.MonthLocator()
formatter = mdates.ConciseDateFormatter(locator)
ax.xaxis.set_major_locator(locator)
ax.xaxis.set_major_formatter(formatter)
plt.show()
This code produces the following dataframe:

As you can see there is no year in the data. In this particular case i had removed the year because the data i am looking to analyze is not a financial time series data. As such I need the plot to start from Jan instead of it printing 1970. So with mdates.MonthLocator() it is adding 1970 on the x-axis of the plot. Is there any way i can remove the year label and have the plot start from Jan?
