Python Matplotlib Y-Axis ticks on Right Side of Plot

后端 未结 4 1767
傲寒
傲寒 2020-11-30 20:51

I have a simple line plot and need to move the y-axis ticks from the (default) left side of the plot to the right side. Any thoughts on how to do this?

4条回答
  •  一生所求
    2020-11-30 21:17

    For right labels use ax.yaxis.set_label_position("right"), i.e.:

    f = plt.figure()
    ax = f.add_subplot(111)
    ax.yaxis.tick_right()
    ax.yaxis.set_label_position("right")
    plt.plot([2,3,4,5])
    ax.set_xlabel("$x$ /mm")
    ax.set_ylabel("$y$ /mm")
    plt.show()
    

提交回复
热议问题