【发布时间】:2022-10-08 02:14:39
【问题描述】:
我是 sympy 绘图的新手,当我反复尝试为像 here 这样的一个变量线性不等式绘制解决方案集时,我无法弄清楚,谁能帮我解决我的问题?
我的代码是这样的
from sympy import symbols, plot
from sympy.plotting import plot
from sympy import *
import numpy as np
x, y = symbols("x, y", real=True)
init_printing(use_unicode=True)
ekpr = (4*x - 2 <= 5 + 3*x)
pprint(ekpr)
xs = np.linspace(0, 10, 11)
yvals = [solve(ekpr, x, xi) for xi in xs]
sol = solve(ekpr, x)
print(sol)
plot = plot(ys, xlim=[0.0, 10.10],
markers=[{'args': [sol, [0], xs, yvals, 'ro']}])
我期望的图表结果如下图所示。 enter image description here
【问题讨论】:
-
请告诉我们您想用以下代码行做什么:
yvals = [solve(ekpr, x, xi) for xi in xs]