How to hide ticks label in python but keep the ticks in place?

后端 未结 3 1936
星月不相逢
星月不相逢 2020-12-16 09:09

I want to hide my ticks label on a plot I created, but keep this tick itself (the little marks on the axis). When I try to use what I\'ve found here, for example, the entire

3条回答
  •  情书的邮戳
    2020-12-16 09:33

    Here is a slightly simpler answer, using ax.tick_params

    import matplotlib.pylab as plt
    
    fig, ax = plt.subplots()
    plt.plot([1,2,3],[4,5,6])
    
    ax.tick_params(labelbottom=False)    
    
    plt.show()
    

    Here is the resulting output in Matplotlib 3

    As commented by @chris, one can similarly hide the labels on any of the other axes using labeltop, labelleft, labelright, in the above example, instead of labelbottom.

提交回复
热议问题