Modify tick label text

前端 未结 10 1458
遥遥无期
遥遥无期 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 07:55

    The axes class has a set_yticklabels function which allows you to set the tick labels, like so:

    #ax is the axes instance
    group_labels = ['control', 'cold treatment',
                 'hot treatment', 'another treatment',
                 'the last one']
    
    ax.set_xticklabels(group_labels)
    

    I'm still working on why your example above didn't work.

提交回复
热议问题