문제

I can remove the tick labels with:

ax.axes.get_yaxis().set_visible(False)

But that removes the ticks as well. I want to preserve the ticks.

도움이 되었습니까?

해결책

Just use a NullFormatter

ax = plt.gca()
ax.yaxis.set_major_formatter(matplotlib.ticker.NullFormatter())
plt.draw()

다른 팁

+1 for @tcaswell answer, I guess that's the standard way to do so. But it has the drawback that the formatter is now missing, and when you move the mouse on your plot you do not get the coordinates of the point the mouse is pointing to.

This is a nice feature I usually rely on, especially because the "data cursor" tool (link) present in Matlab is missing in Matplotlib by default (see mpldatacursor for a plugin with similar features). In Matplotlib I use to hover on a point with the mouse, and read the 'live' coordinates provided by the Formatter.

To turn off the labels without killing the formatter you can use

plt.setp(ax.get_yticklabels(), visible=False)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top