Matplotlib pyplot - 显示没有调整大小以适应数字

时间:2017-02-27 10:47:28

标签: python matplotlib

通过在线阅读(例如here,虽然它们导入pylab而不是pyplot,我从中得到相同的结果),当使用pyplot的show方法时,它应该自动重新缩放图形以包含图例如果它是被放置在主图之外;但是,我的代码似乎没有发生这种情况。

有没有人对如何做到这一点有任何想法?感谢。

# Cut down example of graph drawing, with cut-off legend

plt.xlim([0,1])
plt.ylim([0,1])

line_x = line[t2][0::2]
line_y = line[t2][1::2]

plt.plot(line_x, line_y, label="Line")

plt.grid("on")
plt.tight_layout()
plt.legend(bbox_to_anchor=(1.01, 0.5), loc="center left")

plt.show()

Graph with cut-off legend

0 个答案:

没有答案