我想更改由matplotlib.gridspec
生成的网格的某些轴,以便删除上轴和右轴,并在下轴和左轴的尖端放置箭头。
我已经看到了这个主题here,尤其是答案链接到matplotlib documentation。直接将其与gridspec
产生的斧头一起使用会导致:
TypeError: 'method' object is not subscriptable
如何将这段代码与由gridspec
产生的斧头一起使用?
我已经设法替换了:
for direction in ["left", "right", "bottom", "top"]:
# hides borders
ax.axis[direction].set_visible(False)
作者:
for direction in ["left", "right", "bottom", "top"]:
# hides borders
ax.spines[direction].set_visible(False)
我应该替换为什么
for direction in ["xzero", "yzero"]:
# adds arrows at the ends of each axis
ax.axis[direction].set_axisline_style("-|>")
# adds X and Y-axis from the origin
ax.axis[direction].set_visible(True)