Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Matplotlib Step Graphic: xaxis generates one month too much
-
I want to draw a step graph, the x-axis with the names of months of my data.
Each year contains values from months 01 to 12, and I would have an axis displaying the 12 months of the year, but my code displays an axis from Jan to Jan.
I would hope that the Jan after Dec would not be there...
Sorry if I'm not clear enough (English is not my mother language)
Thanks for your helpCode
ax.step(x,y,'-',where='pre',label=yyyy_prec+' ['+str(ymax)+']',color=colors[color_index-1])
plt.legend(loc=9,fontsize=10)
months = mdates.MonthLocator(range(1,13), bymonthday=1, interval=1) # every month
ax.xaxis.set_major_locator(months)
monthsfmt = mdates.DateFormatter('%b')
ax.xaxis.set_major_formatter(monthsfmt)
ax.yaxis.tick_left()
ax.yaxis.tick_right()
ax.grid(True) -
Resolved
ax.set_xticklabels((...)) and set last tick label as an empty string