4

Is it possible to plot two implicit functions on the same canvas with sympys plot_implicit function?

E.g. have both lines from the two plots in the example be shown on one canvas.

from sympy import *
x,y = symbols('x y')
init_printing()
plot_implicit(Eq(abs(x)+abs(y), 1), (x,-1,1), (y, -1,1))
plot_implicit(Eq(x**2 + y**2, 1), (x,-1,1), (y, -1,1))

1 Answer 1

6

To combine two plots with sympy's plotting, the plots are first created with show=False, then appended and ultimately shown:

from sympy import symbols, plot_implicit, Eq, Abs

x, y = symbols('x y')
plot1 = plot_implicit(Eq(Abs(x) + Abs(y), 1), (x, -1, 1), (y, -1, 1),
                      line_color='steelblue', show=False)
plot2 = plot_implicit(Eq(x ** 2 + y ** 2, 1), (x, -1, 1), (y, -1, 1),
                      line_color='crimson', show=False)
plot1.append(plot2[0])
plot1.show()

resulting plot

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.