Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here are two ways to get the plot you want, one with vertical walls, one without.

If you don't mind the walls, define a function that is x2 where you want and 0 elsewhere. Then plot it.

sage: f = lambda x, y: x^2 if 1 <= x <= 2 and 0 <= y <= x else 0
sage: p = plot3d(f, (-3, 3), (-3, 3), plot_points=100)
sage: p.show(aspect_ratio=1, viewer='threejs')

If you prefer without walls, use the fact that Sage's 3D plotting functions plot nothing if they get something that evaluates to "not a number".

sage: nan = float(NaN)
sage: f = lambda x, y: x^2 if 1 <= x <= 2 and 0 <= y <= x else nan
sage: g = lambda x, y: nan if 1 <= x <= 2 and 0 <= y <= x else 0
sage: qf = plot3d(f, (-3, 3), (-3, 3), plot_points=100)
sage: qg = plot3d(g, (-3, 3), (-3, 3), plot_points=100)
sage: q = qf+qg
sage: q.show(aspect_ratio=1, viewer='threejs')