Hide axis values but keep axis tick labels in matplotlib

前端 未结 6 1306
星月不相逢
星月不相逢 2021-01-30 06:13

I have this image:

plt.plot(sim_1[\'t\'],sim_1[\'V\'],\'k\')
plt.ylabel(\'V\')
plt.xlabel(\'t\')
plt.show()

I want to hide the numbers

6条回答
  •  隐瞒了意图╮
    2021-01-30 06:34

    If you use the matplotlib object-oriented approach, this is a simple task using ax.set_xticklabels() and ax.set_yticklabels():

    import matplotlib.pyplot as plt
    
    # Create Figure and Axes instances
    fig,ax = plt.subplots(1)
    
    # Make your plot, set your axes labels
    ax.plot(sim_1['t'],sim_1['V'],'k')
    ax.set_ylabel('V')
    ax.set_xlabel('t')
    
    # Turn off tick labels
    ax.set_yticklabels([])
    ax.set_xticklabels([])
    
    plt.show()
    

提交回复
热议问题