ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 21 May 2012 02:37:54 -0500multiple parametric_plot's with for loophttps://ask.sagemath.org/question/8988/multiple-parametric_plots-with-for-loop/I'm studying differential geometry of curves and surfaces, and I have a question regarding multiple plots on one graphics, that is i want to plot multiple lines on one plot in for loop, but when I try to do that it shows only the last plot...
a,b,v,u = var('a b v u'); rectangular=(a,b,v);
z=0;
for i in range(81):
z=i*pi/20;z
pt=plot3d(z*v,(v,0,5),(a,0,5),(b,0,5),transformation=rectangular,plot_points=80,color="blue")
show(pt)Sun, 20 May 2012 23:47:33 -0500https://ask.sagemath.org/question/8988/multiple-parametric_plots-with-for-loop/Answer by ndomes for <p>I'm studying differential geometry of curves and surfaces, and I have a question regarding multiple plots on one graphics, that is i want to plot multiple lines on one plot in for loop, but when I try to do that it shows only the last plot...</p>
<pre><code>a,b,v,u = var('a b v u'); rectangular=(a,b,v);
z=0;
for i in range(81):
z=i*pi/20;z
pt=plot3d(z*v,(v,0,5),(a,0,5),(b,0,5),transformation=rectangular,plot_points=80,color="blue")
show(pt)
</code></pre>
https://ask.sagemath.org/question/8988/multiple-parametric_plots-with-for-loop/?answer=13596#post-id-13596You have to 'add' the plots.
I guess you want do something like the following:
a,b,v,u = var('a b v u');
rectangular=(a,b,v);
pt = Graphics()
for i in range(3):
z=i*pi/20
pt += plot3d(z*v,(v,0,5),(a,0,5),(b,0,5),transformation=rectangular,plot_points=80,opacity=0.5)
show(pt)
alternatively you can use list comprehension
plots = [ plot3d(i*pi/20*v,(v,0,5),(a,0,5),(b,0,5),transformation=rectangular,plot_points=80 ) for i in range(3) ]
show(sum(plots))
Mon, 21 May 2012 02:37:54 -0500https://ask.sagemath.org/question/8988/multiple-parametric_plots-with-for-loop/?answer=13596#post-id-13596