Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 32

3D Plotting Example

With Color and Transparency

In class, we talked about integrating over the region trapped by z=x2+3y2z = x^2 + 3 y^2, z=0z = 0, y=xy = x, x=0x = 0, and y=1y =1. I generated a 3D plot in sage to represent this. I used plot_3d and implicit_plot3d to make the surfaces (just as we did in our earlier examples), then added the resulting plots to see all of them together. Note that I named the plots and then added them for my own convenience.

Additionally, I added a color argument to make some of the surfaces green, and also added opacity to make some of the surfaces see-through. Sage recognizes many color names (in quotes) like "green", "red", "orange", etc., including most colors you can think of (and quite a few you might not). (Type sorted(colors) at the Sage prompt to get a list of color names Sage recognizes.) The opacity argument can range from 0 (invisible) to 1 (completely opaque).

var("x, y, z"); s1 = plot3d(x^2 + 3*y^2, (x, 0, 1), (y, 0, 1)) yex = implicit_plot3d(y==x, (x, 0, 1), (y, 0, 1), (z, 0, 4), color="green", opacity=.5) xe0 = implicit_plot3d(x==0, (x, -.1, 1), (y, 0, 1), (z, 0, 4), color="green", opacity=.5) xyp = plot3d(0, (x, 0, 1), (y, 0, 1), color="blue", opacity=.5) ye1 = implicit_plot3d(y==1, (x, 0, 1), (y, 0, 1), (z, 0, 4), color="green", opacity=.5)
(x, y, z)
s1 + yex + xe0 + xyp + ye1
3D rendering not yet implemented