python - 如何绘制 (1+x)(1+y)>=20?

标签 python matplotlib

在 python 中,我想绘制这个区域。

(1+x)*(1+y) >= 20

我不知道如何在 matplotlib 中做到这一点。我在 Internet 上搜索并找到了 fillplots 包,但我不明白如何将它用于两个变量。

这是填充图中的示例:

from fillplots import plot_regions
plotter = plot_regions([
    [(lambda x: x ** 2,),  # x ^ 2 > 0 and
     (lambda x: x + 5,)],  # x + 5 > 0
])

最佳答案

我没有足够的声誉来发表评论。我喜欢 Severin 的情节,但数学不正确。如果 y 为 -1,则该语句的计算结果为 0 且不能 >= 20。左下象限(和右上象限)是否应该有阴影,而不是中间?我认为这与 negative * negative 以及方程式的转换方式有关。

编辑:我尝试编辑 previous answer .我认为这接近要求的内容。垂直线是边界(实际上没有阴影),可以使用技术进行编辑 here .

from fillplots import plot_regions

plotter = plot_regions([

    # positive y+1 values (require positive x+1)
    # plotted in blue in this image
    [(lambda x: 20.0/(1.0+x) - 1.0,),        # False (default) means y > equation
     (-1,)                                   # and y > -1
    ],

    # y < -1 returns a negative value for (y+1) and requires
    # (x+1) to also have a negative value
    # plotted in green in this image
    [(lambda x: 20.0/(1.0+x) - 1.0, True),   # True means y < equation 
     (-1, True)                              # and y < -1
    ],

], xlim=(-40,40), ylim=(-40, 40))

plt.show()

fillplots positive and negative fills

关于python - 如何绘制 (1+x)(1+y)>=20?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35532113/

相关文章:

python - Python 中的高级/抽象 Canbus 接口(interface)

python - 自动编码器分类绘制 Roc 曲线

python - 安装 "scientific python"环境: OS X 10. 7 + Numpy + Scipy + Matplotlib

python - 如何使用 matplotlib 在现有绘图上绘制 float 饼图

matplotlib - 制作带有为每个点指定的标准偏差/置信区间的 seaborn 线图

Python,从另一个类调用类函数

python - 在 Python 中从 int 更改为 int32

python - 删除字符串的隐藏部分时遇到问题

python - SQLAlchemy 中列值作为 `REGEXP` 模式?

python - 将辅助数据绘制为第二个 y 轴上的刻度