GridSpec轴中matplotlib轴顶端的箭头

时间:2020-04-13 16:10:42

标签: python matplotlib

我想更改由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)

0 个答案:

没有答案