Ask Your Question
1

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

asked 2021-12-22 23:45:43 +0100

Konstantin gravatar image

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.add_primitive(pl2)
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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-12-23 04:25:21 +0100

slelievre gravatar image

updated 2021-12-24 20:11:09 +0100

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)
edit flag offensive delete link more

Comments

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,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-12-23 08:27:43 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-12-22 23:45:43 +0100

Seen: 684 times

Last updated: Dec 24 '21