您可以使用contour
進行隱式函數繪圖。順便說一句,我不認爲你可以在同一個圖上繪製不等式的多個函數,因爲你必須在2D平面上顯示範圍,並且它們相互重疊。
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 5, 100)
y = np.linspace(0, 40, 100)
X, Y = np.meshgrid(x, y)
XY1 = (-12.8*X - 0.108*Y + X*Y) >= -1.3824
XY2 = - 40*X - 5*Y + X*Y >= -200
XY3 = - 40*X - 0.108*y + X*Y <= -4.32
XY4 = - 12.8*X - 5*Y + X*Y <= -64
plt.contour(X,Y, XY1)
plt.contour(X,Y, XY2)
plt.contour(X,Y, XY3)
plt.contour(X,Y, XY4)
plt.show()
=========================================== =====================
UPDATE:
好像sympy
的plot_implicit
作品要好得多。您可能需要安裝它。
from sympy import plot_implicit, symbols, And
x, y = symbols('x y')
p1 = plot_implicit(And(-12.8*x - 0.108*y + x*y >= -1.3824), (x,0,5), (y,0,40))
p2 = plot_implicit(And(-40*x - 5*y + x*y >= -200), (x,0,5), (y,0,40))
p3 = plot_implicit(And(-40*x - 0.108*y + x*y <= -4.32), (x,0,5), (y,0,40))
p4 = plot_implicit(And(-12.8*x - 5*y + x*y <= -64), (x,0,5), (y,0,40))
結果: