Python hide ticks but show tick labels

前端 未结 9 818
Happy的楠姐
Happy的楠姐 2020-12-07 11:23

I can remove the ticks with

ax.set_xticks([]) 
ax.set_yticks([]) 

but this removes the labels as well. Any way I can plot the tick labels b

9条回答
  •  无人及你
    2020-12-07 11:51

    You can set the tick length to 0 using tick_params (http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.tick_params):

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot([1],[1])
    ax.tick_params(axis=u'both', which=u'both',length=0)
    plt.show()
    

提交回复
热议问题