Python hide ticks but show tick labels

前端 未结 9 820
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:58

    You can set the yaxis and xaxis set_ticks_position properties so they just show on the left and bottom sides, respectively.

    ax.yaxis.set_ticks_position('left')
    ax.xaxis.set_ticks_position('bottom')
    

    Furthermore, you can hide the spines as well by setting the set_visible property of the specific spine to False.

    axes[i].spines['right'].set_visible(False)
    axes[i].spines['top'].set_visible(False)
    

提交回复
热议问题