我有一个Semilogx图,我想删除xticks。我试过了:
plt.gca().set_xticks([]) plt.xticks([]) ax.set_xticks([])
网格消失(确定),但仍保留小刻度线(在主刻度线的位置)。如何删除它们?
该tick_params方法对于这样的事情非常有用。此代码关闭主要和次要刻度线,并从x轴删除标签。
tick_params
from matplotlib import pyplot as plt plt.plot(range(10)) plt.tick_params( axis='x', # changes apply to the x-axis which='both', # both major and minor ticks are affected bottom=False, # ticks along the bottom edge are off top=False, # ticks along the top edge are off labelbottom=False) # labels along the bottom edge are off plt.show() plt.savefig('plot') plt.clf()