Matplotlib, plotting pandas series: AttributeError: 'tuple' object has no attribute 'xaxis'

早过忘川 提交于 2019-12-06 06:40:52

You are creating 111 subplots. Change:

ax = plt.subplots(111)

into:

ax = plt.subplot(111)

and you it should work. It creates one subplot array of one row, one column, and one subplot. For example, this:

plt.subplot(231)
plt.subplot(236)

creates subplot 1 and subplot 6 in array of 2 rows and 3 columns:

You make the months visible with:

ax.xaxis.set_minor_formatter(matplotlib.dates.DateFormatter('%B'))

Th year an the month are printed on top of each other. One solution is to have the years on the top and the months on bottom:

ax.xaxis.set_tick_params(labeltop='on', labelbottom='off')

Use:

mloc = matplotlib.dates.MonthLocator(range(1, 12, 4))

to show only every fourth month.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!