CoCalc Public Filesshading_test_3D_plots.sagewsOpen with one click!
Author: Greg Hammett
Views : 171
Description: example of lack of shading in 3D plot in CoCalc
Compute Environment: Ubuntu 18.04 (Deprecated)

I'm trying to figure out how to get shading and light reflection on 3D surfaces working properly, as needed for professional quality 3D images. This works at, and appears to work in a sample figure in the documentation, but doesn't work right at

This is a plotting example from

You can search for "cylinder" to find the example. That example says that executing these two lines:


should produce the figure:

![](./Figs/Jmol_orig.png "3D cylindrical surface with shading")

This is a good figure with shading used to help give it a 3D feel. This shading appears to be based on a light source behind and to the left of the viewer. This figure can be reproduced exactly at, as you can see at

[SageMathCell 3D plotting example](

(Scroll down for more comments.)

# Here are the same 2 commands executed in The # result is an image with no shading (except for slightly darker # vertical stripes in the middle of the cylinder): _=var('theta,z') cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2))
3D rendering not yet implemented
show(cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)), viewer="tachyon")
# Interesting that the above command works if the viewer option is given to "show", # but not if it is given directly to "cyclindrical_plot3d", as shown next, # where the viewer option is ignored and it always reverts to this vanilla default # viewer without shading (but it does support rotation): # cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2),viewer="tachyon")
3D rendering not yet implemented
# other viewers not presently implemnted in CoCalc: #show(cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)), viewer="jmol")
#show(cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)), viewer="canvas3d")
#show(cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)), viewer="threejs")
show(cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)), viewer="tachyon")
show(cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)), viewer="tachyon", light=((10,3,2), 0.2, (1,1,1)))