我希望只有左轴和底轴,而不是默认的“长方体”轴样式,即:
+------+ |
| | |
| | ---> |
| | |
+------+ +-------
这应该很简单,但我在文档中找不到必要的选项。
发布于 2014-12-08 23:58:28
这是官方网站HERE推荐的Matplotlib3解决方案
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
ax = plt.subplot(111)
ax.plot(x, y)
# Hide the right and top spines
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
# Only show ticks on the left and bottom spines
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
plt.show()
发布于 2011-11-04 23:20:04
或者,这是
def simpleaxis(ax):
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
在不丢失旋转标签支持的情况下,似乎可以在轴上实现相同的效果。
(Matplotlib 1.0.1;受this启发的解决方案)。
https://stackoverflow.com/questions/925024
复制相似问题