I have two lists: one is dates and othe is data.
alldates = Index(['2019-01-25', '2019-01-26', ...'2019-05-09'], dtype='object')
data = [0.9868203770867318, .... ,0.9257586144368741]
I want to plot them. My code and result is:
plt.plot(alldates,data,'-*',label='R$^2$ score')
plt.locator_params(axis='x', nbins=5)
plt.ylim([-1,1.2])
plt.legend(loc='best')
plt.show()
Plot is:
Also it was giving some error message:
C:\Users\MMatam\Anaconda3\lib\site-packages\matplotlib\ticker.py:
1437: UserWarning: 'set_params()' not defined for locator
of type <class 'matplotlib.category.StrCategoryLocator'>
str(type(self)))
Did you see the x-axis ticks? Looks like my plt.locator_params(axis='x', nbins=5)
did not work. How to get only few ticks on this axis?