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()
7 回答
试试这个删除标签(但不是刻度线):
example
此代码段可能有助于仅删除xticks .
这段代码可能有助于删除xticks和yticks .
tick_params方法对于这样的东西非常有用 . 此代码关闭主要和次要刻度,并从x轴中删除标签 .
不完全是OP所要求的,但是禁用所有轴线,刻度线和标签的简单方法是简单地调用:
这是我在matplotlib mailing list上找到的替代解决方案:
或者,您可以传递空的刻度位置并标记为
有一个比John Vinyard给出的更好,更简单的解决方案 . 使用
NullLocator
:希望有所帮助 .