0
Full date on xticks Python matplotlib
xticks is only showing year. plt.plot(data_comb.index , data_comb['Price']) plt.xticks(dates_list) REFERENCES: type(data_comb.index) is <class 'pandas.core.indexes.datetimes.DatetimeIndex'> type(dates_list) is <class 'list'> type(data_comb.index[0]) is <class 'pandas._libs.tslibs.timestamps.Timestamp'> type(dates_list[0]) is <class 'datetime.datetime'> print(data_comb.index) gives DatetimeIndex(['2020-12-02', '2020-12-01',.., dtype='datetime64[ns]', name='Date', length=503, freq=None) print(dates_list) gives [datetime.datetime(2018, 12, 4, 0, 0), datetime.datetime(2019, 1, 2, 0, 0)]
1 ответ
0
#does something like this help?
#also, for what is worth, I prefer Seaborn over Matplotlib
import matplotlib.dates as mdates
myFmt = mdates.DateFormatter('%d')
ax.xaxis.set_major_formatter(myFmt)
#https://matplotlib.org/examples/api/date_demo.html