# 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.

edit retag close merge delete

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:

f(x,y)=y/(1+x^2*y^2)
fx(x,y)=f.diff(x)
fy(x,y)=f.diff(y)

pf=plot3d(f,(x,-1,1),(y,-1,1),color='black',opacity=.4)
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,pfy]

h = sum(L[i].translate((3*i,0,0)) for i in range(len(L)))
h.show()

( 2024-07-29 07:32:36 +0200 )edit

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 default jmol viewer or the dedicated tachyon viewer. See their respective documentations.

• Stitch up such images, using, for example, the pillow or the matplotlib libraries, both included in Sage.

A bit of Googling suggests that this second step can be done in many ways.

HTH,

( 2024-07-29 09:33:55 +0200 )edit