1

I want to plot something with respect of 12 months. but in figure in x axis, it does not show all 12 month. what I have to do in order to x axis be based on all 12 months?

My code is as follows

plt.plot_date(tezos2018['Date'],tezos2018['Market Cap'], linestyle='solid',xdate=True)
plt.gcf().autofmt_xdate()
date=dates.DateFormatter( '%b , %d, %Y')
plt.gca().xaxis.set_major_formatter(date)

which outputs

The picture of the following code

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74

1 Answers1

0

Make ticks on occurrences of each month, e.g., 1, 3, 12.

Mark every month in bymonth; bymonth can be an int or sequence. Default is range(1,13), i.e. every month.

interval is the interval between each iteration. For example, if interval=2, mark every second occurrence.

import matplotlib.dates as mdates

plt.plot_date(tezos2018['Date'],tezos2018['Market Cap'], linestyle='solid',xdate=True)
plt.gcf().autofmt_xdate()
date=dates.DateFormatter( '%b , %d, %Y')
plt.gca().xaxis.set_major_formatter(date)

plt.gca().xaxis.set_major_locator(mdates.MonthLocator())
  • Thank you. do you know also how I can make the figure wider? –  Aug 16 '20 at 18:56
  • @hghg Take a look at [How do you change the size of figures drawn with matplotlib?](https://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib). –  Aug 16 '20 at 18:58