This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ViewingBox, ViewingBoxXMin, ViewingBoxXMax, ViewingBoxXRange, ViewingBoxYMin, ViewingBoxYMax, ViewingBoxYRange, ViewingBoxZMin, ViewingBoxZMax, ViewingBoxZRange

Visible coordinate range

Value Summary

ViewingBoxLibrary wrapper for "[ViewingBoxXMin .. ViewingBoxXMax, ViewingBoxYMin .. ViewingBoxYMax]" (2D), "[ViewingBoxXMin .. ViewingBoxXMax, ViewingBoxYMin .. ViewingBoxYMax, ViewingBoxZMin .. ViewingBoxZMax]" (3D)See below
ViewingBoxXMax, ViewingBoxXMin, ViewingBoxYMax, ViewingBoxYMin, ViewingBoxZMax, ViewingBoxZMinOptionalMuPAD® expression
ViewingBoxXRange[ViewingBoxXMin .. ViewingBoxXMax]See below
ViewingBoxYRange[ViewingBoxYMin .. ViewingBoxYMax]See below
ViewingBoxZRange[ViewingBoxZMin .. ViewingBoxZMax]See below

Graphics Primitives

ObjectsDefault Values

ViewingBox: [Automatic .. Automatic, Automatic .. Automatic]

ViewingBoxXMin, ViewingBoxXMax, ViewingBoxYMin, ViewingBoxYMax: Automatic

ViewingBoxXRange, ViewingBoxYRange: Automatic .. Automatic


ViewingBox: [Automatic .. Automatic, Automatic .. Automatic, Automatic .. Automatic]

ViewingBoxXMin, ViewingBoxXMax, ViewingBoxYMin, ViewingBoxYMax, ViewingBoxZMin, ViewingBoxZMax: Automatic

ViewingBoxXRange, ViewingBoxYRange, ViewingBoxZRange: Automatic .. Automatic


The ViewingBox attributes set the coordinate range that is visible in a plot.

ViewingBoxXMin = xmin, ViewingBoxXMax = xmax, equivalent to ViewingBoxXRange = xmin .. xmax, restricts the visibility to x values between xmin and xmax. ViewingBoxYMin etc. work analogously.

Setting ViewingBox = [xmin .. xmax, ymin .. ymax] in 2D and ViewingBox = [xmin .. xmax, ymin .. ymax, zmin .. zmax] in 3D

respectively, serves as a short cut for setting the single entries ViewingBoxXMin etc.

The ViewingBox of a plot is computed automatically by default. It is chosen as the smallest box containing all graphical objects in the coordinate system.

The values xmin etc. of the ViewingBox attributes must be real numerical expressions or the special flag Automatic. With Automatic, 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 ViewingBox in such a case.

When using plot::Rotate2d or plot::Rotate3d, the ViewingBox may be larger than necessary. Its size is computed by rotating the common viewing box of all objects in the rotation object. See Example 4.

The ViewingBox of an animation is automatically chosen as the union of all viewing boxes of the frames of the animation.

The ViewingBox itself cannot be animated. However, the object plot::ClippingBox may be used to implement animated visibility regions.


Example 1

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):

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 use Automatic to let MuPAD find the maximal y-value automatically:

plot(f, ViewingBoxYRange = 0..Automatic)

The previous command is equivalent to:

plot(f, ViewingBoxYMin = 0)

delete f:

Example 2

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):

We specify the upper z value of the visible volume:

plot(f, ViewingBoxZRange = Automatic..3)

delete f:

Example 3

Usually, a plot uses the whole drawing aera:

f := plot::Function2d(ln(x), x = 0..2):

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])

delete f:

Example 4

The following viewing box is larger than expected:

c := plot::Ellipse2d(1, 0.5, [0, 0]):
r := plot::Rotate2d(c, PI/3):

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:

Example 5

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)):

See Also

MuPAD Functions

MuPAD Graphical Primitives

Was this topic helpful?