我有一个semilogx图,我想删除xticks.我试过:
plt.gca().set_xticks([])
plt.xticks([])
ax.set_xticks([])
网格消失(正常),但小刻度(在主刻度的位置)仍然存在.如何移除它们?
我有一个semilogx图,我想删除xticks.我试过:
plt.gca().set_xticks([])
plt.xticks([])
ax.set_xticks([])
网格消失(正常),但小刻度(在主刻度的位置)仍然存在.如何移除它们?
plt.tick_params
方法对于这样的东西非常有用.此代码关闭主刻度和次刻度,并从x轴删除标签.
请注意,matplotlib.axes.Axes
个对象也有ax.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()