绘制网格线但隐藏坐标轴。

3

看起来是一个简单的请求,但到目前为止还没有任何运气。我以为这会像这样简单:

import matplotlib.pyplot as plt

fig = plt.plot([1,2], [1,2])
plt.grid(True)
plt.axis('off')

但这样也会去掉网格。

明确一下,我不想要标签、刻度线或粗轴线,只想要网格。

1个回答

4

尝试:

fig, ax = plt.subplots(1,1)
ax.plot([1,2], [1,2])
plt.grid(True)
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_frame_on(False)
ax.tick_params(tick1On=False)
plt.show()

这种面向对象的方法非常有效。在Matlab风格的方法中是否有类似的方法?我并不一定能够访问原始的图形和坐标轴。 - undefined
1
使用gca和gcf? - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接