matplotlib share x axis but don't show x axis tick labels for both, just one

前端 未结 5 826
清酒与你
清酒与你 2020-11-29 19:56

I\'m using python + matplotlib and I\'m having two plots share an axis. If you try to set graph1.set_xticklabels([]) while sharing an axis, it has no effect bec

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 20:41

    You could use Axes.tick_params():

    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    ax1 = fig.add_subplot(211)
    ax2 = fig.add_subplot(212, sharex=ax1)
    
    ax1.tick_params(labelbottom=False)
    

提交回复
热议问题