# How can I plot two parametric functions in a common coordinate system?

I can easily use parametric_plot() to plot 1 parametric function at once. For example

parametric_plot((sin(2*t),cos(3*t)),(t,0.0,9),aspect_ratio=1)


plots a nice Lissajous curve.

I also can plot a circle:

parametric_plot((sin(t),cos(t)),(t,0.0,9),aspect_ratio=1)


But how can I plot both of them in a common coordinate system?

I tried:

parametric_plot([(sin(2*t),cos(3*t)),(sin(t),cos(t))],(t,0.0,9),aspect_ratio=1)


Which doesn't work -> Last error message: ''tuple' object is not callable'

I also tried:

pl1=parametric_plot((sin(t),cos(t)),(t,0.0,9),aspect_ratio=1)
pl2=parametric_plot((sin(2*t),cos(3*t)),(t,0.0,9),aspect_ratio=1)
pl1


Error: 'Graphics' object has no attribute 'options'

Then how can I use parametric_plot() to plot two parametric functions at once, in a common coordinate system?

edit retag close merge delete

Sort by ยป oldest newest most voted

Graphics object can be combined using +.

So in your case this should work:

sage: pl = pl1 + pl2
sage: pl


Edit, inspired by @Emmanuel Charpentier's comment to my initial answer.

This works too:

sage: t = SR.var('t')
sage: xys = [[sin(2*t), cos(3*t)], [sin(t), cos(t)]]
sage: sum(parametric_plot(xy, (t, 0.0, 9.0), aspect_ratio=1) for xy in xys)

more

Alternates to slelievre's solution :

sage: t=SR.var("t")
sage: L=[[sin(2*t),cos(3*t)],[sin(t),cos(t)]]
sage: sum(map(lambda c:parametric_plot(c,(t,0.0,9),aspect_ratio=1), L))
Launched png viewer for Graphics object consisting of 2 graphics primitives
sage: sum(map(lambda c:plot(c,(t,0.0,9),aspect_ratio=1,parametric=True), L))
Launched png viewer for Graphics object consisting of 2 graphics primitives


HTH,

( 2021-12-23 08:27:43 +0200 )edit