Visible coordinate range
|Library wrapper for "[||See below|
ViewingBox attributes set the coordinate
range that is visible in a plot.
xmax, restricts the visibility to x values
xmax, ymin .. ymax] in
xmax, ymin .. ymax,
zmin .. zmax] in
respectively, serves as a short cut for setting the single entries
ViewingBox of a plot is computed automatically
by default. It is chosen as the smallest box containing all graphical
objects in the coordinate system.
ViewingBox attributes must be real numerical
expressions or the special flag
the system chooses appropriate values automatically.
When plotting a function or a curve with singularities, a heuristics
is used to set a "reasonable" restricted viewing box
for the plot. This heuristics sometimes fails to produce a pleasing
picture. We recommended to request an explicit
such a case.
ViewingBox of an animation is automatically
chosen as the union of all viewing boxes of the frames of the animation.
ViewingBox itself cannot be animated.
However, the object
plot::ClippingBox may be used to implement
animated visibility regions.
In the following plot, the horizontal axis is placed at the minmal y-value produced by the function:
f := plot::Function2d(exp(-x^2), x = -1.7 .. 1.7): plot(f)
We wish to make the x-axis
appear at y = 0.
To this end, we request the y range
to start with y = 0 and
Automatic to let MuPAD find the maximal y-value
plot(f, ViewingBoxYRange = 0..Automatic)
The previous command is equivalent to:
plot(f, ViewingBoxYMin = 0)
Here is a 3D plot of a singular function:
f := plot::Function3d((sin(x) + cos(y))/(x^2 + y^2), x = -PI..PI, y = -PI..PI): plot(f)
We specify the upper z value of the visible volume:
plot(f, ViewingBoxZRange = Automatic..3)
Usually, a plot uses the whole drawing aera:
f := plot::Function2d(ln(x), x = 0..2): plot(f)
We extend the viewing box in x direction to make it symmetric w.r.t. x:
plot(f, ViewingBoxXRange = -2..2)
We specify the viewing box both in x and y direction:
plot(f, ViewingBox = [-2..2, -2..2])
The following viewing box is larger than expected:
c := plot::Ellipse2d(1, 0.5, [0, 0]): r := plot::Rotate2d(c, PI/3): plot(r)
The reason is how the viewing box of the rotation is computed. The blue rectangle is the viewing box of the ellipse. The rotated viewing box is the black rectangle. The viewing box of the rotation is the smallest rectangle containing the rotated viewing box of the ellipse (the dashed black rectangle):
rect1 := plot::Rectangle(-1..1, -0.5..0.5, Color = RGB::Black): rect2 := plot::modify(rect1, Color = RGB::Blue): r := plot::Rotate2d(c, rect1, a, a = 0..PI/2): X := cos(a) + 0.5*sin(a): Y := 0.5*cos(a) + sin(a): rect3 := plot::Rectangle(-X..X, -Y..Y, a = 0..PI/2, Color = RGB::Black, LineStyle = Dashed): plot(r, rect2, rect3)
delete c, r, rect1, rect2, rect3, X, Y:
The x-range from - π to π is generated by all frames of the following animation and does not change from frame to frame:
plot(plot::Function2d(sin(x), x = -PI + a .. a, a = 0 .. PI)):