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

后端 未结 3 1935
星月不相逢
星月不相逢 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:26

    I didn't find divenex's answer to work for me. This answer creates ticks without triggering any automatic labeling, hence no requirement to use "labelbottom= False":

    if the bottom and left ticks already exist:

    import matplotlib.pyplot as plt
    
    fig, ax = plt.subplots()
    plt.plot([1,2,3],[4,5,6])
    
    ax.tick_params(right= True,top= True)
    

    if no ticks already exist:

    import matplotlib.pyplot as plt
    
    fig, ax = plt.subplots()
    plt.plot([1,2,3],[4,5,6])
    
    ax.tick_params(right= True,top= True,left= True, bottom= True)
    

提交回复
热议问题