Sympy: plot x,y equation as a curve without solve it

Viewed 20

I got a equation: f = x**3 + 2*x*y + y**2 - 9, I just want direct plot it in x,y plane. But now what I'm doing is first solve(f), then plot the solutions one by one like the graph below, I want to know if is there a way to direct plot a curve from such an equation.

enter image description here

2 Answers

I believe this is the most compact way to achieve what you want.

plot(*solve(f, y), (x, -3, 3))

You can use plot_implicit:

from sympy import symbols, plot_implicit
x, y = symbols('x, y')
f = x**3 + 2*x*y + y**2 - 9
plot_implicit(f, (x, -3, 3), (y, -5, 10))

plot of implicitly defined curve

Related