omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    1
    2
    1151
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp last edited by cvp

      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 help

      Code

      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)

      link text

      1 Reply Last reply Reply Quote 0
      • cvp
        cvp last edited by

        Resolved

        ax.set_xticklabels((...)) and set last tick label as an empty string

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors