【问题标题】:draw matplotlib rectangle patch with infinite length绘制无限长的 matplotlib 矩形补丁
【发布时间】:2011-03-07 16:56:20
【问题描述】:

我似乎找不到在 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 的代码并没有让我更接近解决方案,所以我想我会检查一下这里是否有人能想到解决方法。

【问题讨论】:

    标签: matplotlib patch


    【解决方案1】:

    听起来您更喜欢axhspanaxvspan。示例here

    【讨论】:

    • 感谢 Paul,这正是我所需要的。
    • 但是你如何指定axvspan(1, inf)而不会使情节更宽?
    猜你喜欢
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    • 2021-09-28
    • 1970-01-01
    • 2015-03-18
    • 2013-08-26
    • 2020-05-22
    相关资源
    最近更新 更多