绘制无限长度的 matplotlib 矩形块
我似乎找不到在 matplotlib 中绘制具有无限边长的矩形补丁的方法,也找不到任何关于是否有办法做到这一点的文档或对话。
基本上:
from matplotlib.patches import Rectangle
import numpy as np
x_min = 0
x_range = 1
y_min = -np.inf
y_range = np.inf
Rectangle((x_min, y_min), x_range, y_range)
我意识到 numpy 中的 inf - inf 返回 nan,并且这可能是在某个时刻计算的。
不管怎样,查看 Rectangle 的代码并没有让我更接近解决方案,所以我想我应该检查一下这里是否有人能想出解决办法。
I can't seem to find a way to draw a rectangle patch with infinite side length in matplotlib, nor can I find any documentation or conversations as to whether there is a way to do this.
basically:
from matplotlib.patches import Rectangle
import numpy as np
x_min = 0
x_range = 1
y_min = -np.inf
y_range = np.inf
Rectangle((x_min, y_min), x_range, y_range)
I realize that inf - inf in numpy returns nan, and that this is probably computed at some point.
Anyway, looking at the code for Rectangle didn't get me any closer to a solution, so I thought I'd check and see if anyone on here can think of a way around it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您更愿意拥有
axhspan
或axvspan
。示例此处。It sounds like you would rather have an
axhspan
oraxvspan
. Example here.