How do I plot 3d plots side by side?
I wanted to plot my function and its partial derivatives side by side on a plot. I tried the following thing but it failed,
f(x,y)=y/(1+x^2*y^2)
pf=plot3d(f,(x,-1,1),(y,-1,1),color='black',opacity=.4)
fx(x,y)=f.diff(x)
fy(x,y)=f.diff(y)
pfx=plot3d(fx,(x,-1,1),(y,-1,1),color='green',opacity=.4)
pfy=plot3d(fy,(x,-1,1),(y,-1,1),color='red',opacity=.4)
L=[pf,pfx]
G=graphics_array(L,1)
G.show(figsize=4)
Thanks.
As far as I'm concerned,
graphics_array
is implemented only for 2D plots. Using the reply of @niles at https://ask.sagemath.org/question/7896/multiple-3d-plots-in-one-panel-graphics_array-and-3d/, the following can be regarded as a workaround:Not a full answer, but some ideas.
There is no such thing as a 3D graphics array in Sage. But you might :
Save 2D renderings of your 3D plots in separate image files (e. g.
png
), using either the oprtions of the defaultjmol
viewer or the dedicatedtachyon
viewer. See their respective documentations.Stitch up such images, using, for example, the
pillow
or thematplotlib
libraries, both included in Sage.A bit of Googling suggests that this second step can be done in many ways.
HTH,