Modify tick label text

前端 未结 10 1451
遥遥无期
遥遥无期 2020-11-22 07:13

I want to make some modifications to a few selected tick labels in a plot.

For example, if I do:

label = axes.yaxis.get_major_ticks()[2].label
label         


        
10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 08:12

    One can also do this with pylab and xticks

    import matplotlib
    import matplotlib.pyplot as plt
    x = [0,1,2]
    y = [90,40,65]
    labels = ['high', 'low', 37337]
    plt.plot(x,y, 'r')
    plt.xticks(x, labels, rotation='vertical')
    plt.show()
    

    http://matplotlib.org/examples/ticks_and_spines/ticklabels_demo_rotation.html

提交回复
热议问题