matplotlib format_coord文本正在包装

时间:2018-02-02 07:45:44

标签: python matplotlib

我正在使用Matplotlib的Axes.format_coord同时显示几条曲线的y-coords,并且文本足够长,以便它包裹到一条新线,这条线只是部分可见。这是显示问题的图的下边缘的图像。有没有办法增加为format_coord文本分配的空间长度?谢谢你的帮助。

Bottom edge of figure showing issue.

编辑:我在Mac OS X High Sierra上运行,使用python 3.6和matplotlib 2.1.1,当使用IDLE和命令行运行代码时会出现问题。这里有一些代码会产生同样的问题:

from matplotlib import pyplot as plt
from math import pi, sin

N = 30
x = [n/N for n in range(5*N)]
y = [sin(n*pi/N) for n in range(5*N)]

ax = plt.figure().add_subplot(1, 1, 1)
ax.format_coord = lambda x, y : 'the x-coordinate = ' + format(x, '1.4f') + ', ' + \
                                'the y-coordinate = ' + format(y, '1.4f')
plt.plot(x, y)
plt.show()

在准备这个样本时,我注意到拉伸图形窗口使其更宽不会增加坐标文本的可用空间。同样地,使窗口变窄不会减少可用空间,并且坐标文本会在窗口的右边缘被切断。

0 个答案:

没有答案