Warm tip: This article is reproduced from serverfault.com, please click

matplotlib-Python隐藏壁虱但显示壁虱标签

(matplotlib - Python hide ticks but show tick labels)

发布于 2015-05-01 13:58:01

我可以用

ax.set_xticks([]) 
ax.set_yticks([]) 

但这也会删除标签。我可以以任何方式绘制刻度线标签,但不能绘制刻度线和书脊

Questioner
user308827
Viewed
44
Julien Spronck 2015-05-01 22:14:08

你可以使用tick_paramshttp://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.tick_params将刻度长度设置为0

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1],[1])
ax.tick_params(axis=u'both', which=u'both',length=0)
plt.show()