Easy Plotting: Graphs of Functions

The probably most important graphical task in a mathematical context is to visualize function graphs, i.e., to plot functions. There are two graphical routines plotfunc2d and plotfunc3d which allow to create 2D plots of functions with one argument (such as f(x) = sin(x), f(x) = x*ln(x) etc.) or 3D plots of functions with two arguments (such as f(x, y) = sin(x^2 + y^2), f(x, y) = y*ln(x) - x*ln(y) etc.). The calling syntax is simple: just pass the expression that defines the function and, optionally, a range for the independent variable(s).

2D Function Graphs: plotfunc2d

We consider 2D examples, i.e., plots of univariate functions y = f(x). Here is one period of the sine function:

plotfunc2d(sin(x), x = 0..2*PI):

If several functions are to be plotted in the same graphical scene, just pass a sequence of function expressions. All functions are plotted over the specified common range:

plotfunc2d(sin(x)/x, x*cos(x), tan(x), x = -4..4):

Functions that do not allow a simple symbolic representation by an expression can also be defined by a procedure that produces a numerical value f(x) when called with a numerical value x from the plot range. In the following example we consider the largest eigenvalue of a symmetric 3×3 matrix that contains a parameter x. We plot this eigenvalue as a function of x:

f := x -> max(numeric::eigenvalues(matrix([[-x, x, -x  ], 
                                           [ x, x,  x  ], 
                                           [-x, x,  x^2]]))):
plotfunc2d(f, x = -1..1):

The name x used in the specification of the plotting range provides the name that labels the horizontal axis. Functions can also be defined by piecewise objects:

plotfunc2d(piecewise([x < 1, 1 - x],
                     [1 < x and x < 2, 1/2],
                     [x > 2, 2 - x]),
           x = -2..3)

Note that there are gaps in the definition of the function above: no function value is specified for x = 1 and x = 2. This does not cause any problem, because plotfunc2d simply ignores all points that do not produce real numerical values. Thus, in the following example, the plot is automatically restricted to the regions where the functions produce real values:

plotfunc2d(sqrt(8 - x^4), ln(x^3 + 2)/(x - 1), x = -2 ..2):

When several functions are plotted in the same scene, they are drawn in different colors that are chosen automatically. With the Colors attribute one may specify a list of RGB colors that plotfunc2d shall use:

plotfunc2d(x, x^2, x^3, x^4, x^5, x = 0..1,
           Colors = [RGB::Red, RGB::Orange, RGB::Yellow, 
                     RGB::BlueLight, RGB::Blue]):

Animated 2D plots of functions are created by passing function expressions depending on a variable (x, say) and an animation parameter (a, say) and specifying a range both for x and a:

plotfunc2d(cos(a*x), x = 0..2*PI, a = 1..2):

Once the plot is created, the first frame of the picture appears as a static plot. After clicking on the picture, the graphics tool starts playing the animation. There are the usual controls to stop, start, and fast-forward/rewind the animation.

The default number of frames of the animation is 50. If a different value is desired, just pass the attribute Frames = n, where n is the number of frames that shall be created:

plotfunc2d(sin(a*x), sin(x - a), x = 0..PI, a = 0..4*PI, 
           Colors = [RGB::Blue, RGB::Red], Frames = 200):

Apart from the color specification or the Frames number, there is a large number of further attributes that may be passed to plotfunc2d. Each attribute is passed as an equation AttributeName = AttributeValue to plotfunc2d. Here, we only present some selected attributes. See the section on attributes for plotfunc for further tables with more attributes.

attribute name possible values/examplemeaningdefault
Height8*unit::cmphysical height of the picture80*unit::mm
Width12*unit::cmphysical width of the picture120*unit::mm
Footerstringfooter text"" (no footer)
Headerstringheader text"" (no header)
Titlestringtitle text"" (no title)
TitlePosition[real value, real value]coordinates of the lower left corner of the title 
GridVisibleTRUE, FALSEvisibility of "major" grid lines in all directionsFALSE
SubgridVisibleTRUE, FALSEvisibility of "minor" grid lines in all directionsFALSE
AdaptiveMeshinteger ≥ 2number of sample points of the numerical mesh121
AxesNone, Automatic, Boxed, Frame, Originaxes typeAutomatic
AxesVisibleTRUE, FALSEvisibility of all axesTRUE
AxesTitles[string, string]titles of the axes["x","y"]
CoordinateTypeLinLin, LinLog, LogLin, LogLog linear-linear, linear-logarithmic, logarithmic-linear, log-log LinLin
Colorslist of RGB valuesline colorsfirst 10 entries of RGB::ColorList
Framesinteger ≥ 0number of frames of an animation50
LegendVisibleTRUE, FALSElegend on/offTRUE
LineColorTypeDichromatic, Flat, Functional, Monochrome, Rainbowcolor schemeFlat
Meshinteger ≥ 2number of sample points of the numerical mesh121
ScalingAutomatic, Constrained, Unconstrainedscaling modeUnconstrained
TicksNumberNone, Low, Normal, Highnumber of labeled ticks at all axesNormal
VerticalAsymptotesVisibleTRUE, FALSEvertical asymptotes on/offTRUE
ViewingBoxYRangeymin..ymaxrestricted viewing range in y directionAutomatic
YRangeymin..ymax restricted viewing range in y direction (equivalent to ViewingBoxYRange) Automatic

The following plot example features the notorious function that oscillates wildly near the origin:

plotfunc2d(sin(1/x), x = -0.5..0.5):

Clearly, the default of 121 sample points used by plotfunc2d does not suffice to create a sufficiently resolved plot. We increase the number of numerical mesh points via the Mesh attribute. Additionally, we increase the resolution depth of the adaptive plotting mechanism from its default value AdaptiveMesh = 2 to AdaptiveMesh = 4:

plotfunc2d(sin(1/x), x = -0.5..0.5, Mesh = 500,
           AdaptiveMesh = 4):

The following call specifies a header via Header = "The function sin(x^2)". The distance between labeled ticks is set to 0.5 along the x axis and to 0.2 along the y axis via XTicksDistance = 0.5 and YTicksDistance = 0.2, respectively. Four additional unlabeled ticks between each pair of labeled ticks are set in the x direction via XTicksBetween = 4. One additional unlabeled tick between each pair of labeled ticks in the y direction is requested via YTicksBetween = 1. Grid lines attached to the ticks are "switched on" by GridVisible = TRUE and SubgridVisible = TRUE:

plotfunc2d(sin(x^2), x = 0..7,
           Header = "The function sin(x^2)",
           XTicksDistance = 0.5, YTicksDistance = 0.2,
           XTicksBetween = 4, YTicksBetween = 1,
           GridVisible = TRUE, SubgridVisible = TRUE):

When singularities are found in the function, an automatic clipping is called trying to restrict the vertical viewing range in some way to obtain a "reasonably" scaled picture. This is a heuristic approach that sometimes needs a helping adaptation "by hand". In the following example, the automatically chosen range between y ≈ - 1 and y ≈ 440 in vertical direction is suitable to represent the 6th order pole at x = 1, but it does not provide a good resolution of the first order pole at x = - 1:

plotfunc2d(1/(x + 1)/(x - 1)^6, x = -2..2):

There is no good viewing range that is adequate for both poles because they are of different order. However, some compromise can be found. We override the automatic viewing range suggested by plotfunc2d and request a specific viewing range in vertical direction via ViewingBoxYRange:

plotfunc2d(1/(x + 1)/(x - 1)^6, x = -2..2, 
           ViewingBoxYRange = -10..10):

The values of the following function have a lower bound but no upper bound. We use the attribute ViewingBoxYRange = Automatic..10 to let plotfunc2d find a lower bound for the viewing box by itself whilst requesting a specific value of 10 for the upper bound:

plotfunc2d(exp(x)*sin(PI*x) + 1/(x + 1)^2/(x - 1)^4, x = -2..2, 
           ViewingBoxYRange = Automatic..10):

3D Function Graphs: plotfunc3d

We consider 3D examples, i.e., plots of bivariate functions z = f(x, y). Here is a plot of the function sin(x2 + y2):

plotfunc3d(sin(x^2 + y^2), x = -2..2, y = -2..2):

If several functions are to be plotted in the same graphical scene, just pass a sequence of function expressions; all functions are plotted over the specified common range:

plotfunc3d((x^2 + y^2)/4, sin(x - y)/(x - y),
                       x = -2..2, y = -2..2):

Functions that do not allow a simple symbolic representation by an expression can also be defined by a procedure that produces a numerical value f(x, y) when called with numerical values x, y from the plot range. In the following example we consider the largest eigenvalue of a symmetric 3×3 matrix that contains two parameters x, y. We plot this eigenvalue as a function of x and y:

f := (x, y) -> max(numeric::eigenvalues(
                   matrix([[-y, x, -x],
                             [x, y, x],
                          [-x, x, y^2]]))):
plotfunc3d(f, x = -1..1, y = -1..1):

The names x, y used in the specification of the plotting range provide the labels of the corresponding axes. Functions can also be defined by piecewise objects:

plotfunc3d(piecewise([x < y, y - x], [x > y, (y - x)^2]),
                                     x = 0..1, y = 0..1)

Note that there are gaps in the definition of the function above: no function value is specified for x = y. This does not cause any problem, because plotfunc3d simply ignores points that do not produce real numerical values if it finds suitable values in the neighborhood. Thus, missing points do not show up in a plot if these points are isolated or are restricted to some 1-dimensional curve in the x-y plane. If the function is not real valued in regions of nonzero measure, the resulting plot contains holes. The following function is real valued only in the disk x2 + y2 ≤ 1:

plotfunc3d(sqrt(1 - x^2 - y^2), x = 0..1, y = 0..1):

When several functions are plotted in the same scene, they are drawn in different colors that are chosen automatically. With the Colors attribute one may specify a list of RGB colors that plotfunc3d shall use:

plotfunc3d(2 + x^2 + y^2, 1 + x^4 + y^4, x^6 + y^6,
           x = -1..1, y = -1..1,
           Colors = [RGB::Red, RGB::Green, RGB::Blue]):

Animated 3D plots of functions are created by passing function expressions depending on two variables (x, y, say) and an animation parameter (a, say) and specifying a range for x, y, and a:

plotfunc3d(x^a + y^a, x = 0..2, y = 0..2, a = 1..2):

Once the plot is created, the first frame of the picture appears as a static plot. After double-clicking on the picture, the animation starts. The usual controls for stopping, going to some other point in time etc. are available.

The default number of frames of the animation is 50. If a different value is desired, just pass the attribute Frames = n, where n is the number of frames that shall be created:

plotfunc3d(sin(a)*sin(x) + cos(a)*cos(y),
                x = 0..2*PI, y = 0..2*PI,
                a = 0..2*PI, Frames = 32):

Apart from the color specification or the Frames number, there is a large number of further attributes that may be passed to plotfunc3d. Each attribute is passed as an equation AttributeName = AttributeValue to plotfunc3d. Here, we only present some selected attributes. Section Attributes for plotfunc2d and plotfunc3d provides further tables with more attributes.

plotfunc3d

attribute name possible values/examplemeaningdefault
Height8*unit::cmphysical height of the picture 80*unit::mm
Width12*unit::cmphysical width of the picture 120*unit::mm
Footerstring footer text "" (no footer)
Headerstring header text "" (no header)
Titlestring title text "" (no title)
TitlePosition[real value, real value]coordinates of the lower left corner of the title  
GridVisibleTRUE, FALSEvisibility of "major" grid lines in all directions FALSE
SubgridVisibleTRUE, FALSEvisibility of "minor" grid lines in all directions FALSE
AdaptiveMeshinteger ≥ 0depth of the adaptive mesh 0
AxesAutomatic, Boxed, Frame, Originaxes type Boxed
AxesVisibleTRUE, FALSEvisibility of all axes TRUE
AxesTitles[string, string, string]titles of the axes ["x","y","z"]
CoordinateTypeLinLinLin, ..., LogLogLoglinear-linear-linear, linear-logarithmic, logarithmic-linear, log-log plot LinLinLin
Colorslist of RGB valuesfill colors  
Framesinteger ≥ 0number of frames of the animation 50
LegendVisibleTRUE, FALSElegend on/off TRUE
FillColorTypeDichromatic, Flat, Functional, Monochrome, Rainbowcolor scheme Dichromatic
Mesh[integer ≥ 2, integer ≥ 2] number of "major" mesh points [25, 25]
Submesh[integer ≥ 0, integer ≥ 0] number of "minor" mesh points [0, 0]
ScalingAutomatic, Constrained, Unconstrainedscaling mode Unconstrained
TicksNumberNone, Low, Normal, Highnumber of labeled ticks at all axes Normal
ViewingBoxZRangezmin..zmaxrestricted viewing range in z direction Automatic
ZRangezmin..zmaxrestricted viewing range in z direction (equivalent to ViewingBoxZRange) Automatic

In the following example, the default mesh of 25 ×25 sample points used by plotfunc3d does not suffice to create a sufficiently resolved plot:

plotfunc3d(sin(x^2 + y^2), x = -3..3, y = -3..3):

We increase the number of numerical mesh points via the Submesh attribute:

plotfunc3d(sin(x^2 + y^2), x = -3..3, y = -3..3, Submesh = [3, 3])

The following call specifies a header via Header = "The function sin(x - y^2)". Grid lines attached to the ticks are "switched on" by GridVisible = TRUE and SubgridVisible = TRUE:

plotfunc3d(sin(x - y^2), x = -2*PI..2*PI, y = -2..2,
           Header = "The function sin(x - y^2)",
           GridVisible = TRUE, SubgridVisible = TRUE):

When singularities are found in the function, an automatic clipping is called trying to restrict the vertical viewing range in some way to obtain a "reasonably" scaled picture. This is a heuristic approach that sometimes needs a helping adaptation "by hand". In the following example, the automatically chosen range between z ≈ 0 and z ≈ 0.8 in vertical direction is suitable to represent the pole at x = 1, y = 1, but it does not provide a good resolution of the pole at x = - 1, y = 1:

plotfunc3d(1/((x + 1)^2 + (y - 1)^2)/((x - 1)^2 + (y - 1)^2)^5,
                        x = -2..3, y = -2..3, Submesh = [3, 3]):

There is no good viewing range that is adequate for both poles because they are of different order. We override the automatic viewing range suggested by plotfunc3d and request a specific viewing range in the vertical direction via ViewingBoxZRange:

plotfunc3d(1/((x + 1)^2 + (y - 1)^2)/((x - 1)^2 + (y - 1)^2)^5,
                                          x = -2..3, y = -2..3,
                   Submesh = [3, 3], ViewingBoxZRange = 0..0.1):

The values of the following function have a lower bound but no upper bound. We use the attribute ViewingBoxZRange = Automatic..20 to let plotfunc2d find a lower bound for the viewing box by itself whilst requesting a specific value of 20 for the upper bound:

plotfunc3d(1/x^2/y^2 + exp(-x)*sin(PI*y),
                    x = -2..2, y = -2..2,
        ViewingBoxZRange = Automatic..20):

Attributes for plotfunc2d and plotfunc3d

The function plotters plotfunc2d and plotfunc3d accept a large number of attributes (options). In this section we give an overview over the most important attributes. There is a help page for each attribute that provides more detailed information and examples.

Attributes are passed as equations AttributeName = AttributeValue to plotfunc2d and plotfunc3d. Several attributes can be passed simultaneously as a sequence of such equations.

The attributes can be changed interactively in the property inspector. Click on the plot to make subwindows appear for the "object browser" and the "property inspector" (see section Viewer, Browser, and Inspector: Interactive Manipulation). The functions plotted by plotfunc2d and plotfunc3d appear as plot objects of type plot::Function2d and plot::Function3d, respectively. They are embedded in a coordinate system inside a graphical scene. The scene is embedded in a viewing area called the ‘Canvas.' In the viewer, the various plot attributes are associated with the different objects of this graphical hierarchy. Typically, layout parameters and titles are set within the canvas, whilst axes, grid lines, viewing boxes etc. are associated with the coordinate system. Some attributes such as colors, line width, the numerical mesh size etc. belong to the function graphs and can be set separately for each function plotted by plotfunc2d/plotfunc3d.

The last entry in the following tables provides the location of the attribute in the graphical hierarchy of the object browser. For example, for changing the background color of the picture, select the scene by double clicking the ‘Scene2d'/‘Scene3d' entry in the object browser. Now, the property inspector provides a tree of attributes with the nodes ‘Annotation,' ‘Layout,' and ‘Style.' Opening the ‘Style' sub-tree, one finds an entry for BackgroundColor which allows to change the background color interactively.

Here is a table of the most important attributes for setting the layout and the background of the picture:

attribute name possible values/example meaning default browser entry
Width12*unit::cmphysical width of the picture 120*unit::mmCanvas
Height8*unit::cmphysical height of the picture 80*unit::mmCanvas
BackgroundColorRGB color color of the background RGB::WhiteScene2d/3d
BorderColorRGB color color of the border RGB::Grey50Scene2d/3d
BorderWidth1*unit::mmwidth of the border 0Scene2d/3d
Margin1*unit::mmcommon width for all margins: BottomMargin, LeftMargin, etc. 1*unit::mmScene2d/3d
BottomMargin1*unit::mmwidth of bottom margin 1*unit::mmScene2d/3d
LeftMargin1*unit::mmwidth of left margin 1*unit::mmScene2d/3d
RightMargin1*unit::mmwidth of right margin 1*unit::mmScene2d/3d
TopMargin1*unit::mmwidth of top margin 1*unit::mmScene2d/3d
BackgroundStyleFlat, LeftRight, TopBottom, Pyramidbackground style of 3D scenes FlatScene3d
BackgroundColor2RGB color secondary color of the background (used for color blends) RGB::Grey75Scene3d
BackgroundTransparentTRUE, FALSEtransparent background? FALSEScene2d

An overall title can be set as a footer and/or a header. Here is a table of the attributes determining the footer and/or header of the picture:

attribute name possible values/example meaning default browser entry
Footerstring footer text "" (no footer) Scene2d/3d
Headerstring header text "" (no header) Scene2d/3d
FooterAlignmentLeft, Center, Righthorizontal alignment CenterScene2d/3d
HeaderAlignmentLeft, Center, Righthorizontal alignmentCenterScene2d/3d
FooterFontsee section Fontsfont for the footer sans-serif 12 Scene2d/3d
HeaderFontsee section Fontsfont for the header sans-serif 12 Scene2d/3d

Apart from footers and/or headers of scenes and canvas, there are titles associated with the functions. In contrast to footer and header, function titles can be placed anywhere in the coordinate system via the attribute TitlePosition. Typically, titles are associated with individual objects rather than with entire scenes. Thus, when using plotfunc2d or plotfunc3d, a title attribute will usually only be used when a single function is displayed. However, several titles with separate positions can be set interactively in the property inspector for each of the functions:

attribute name possible values/example meaning default browser entry
Titlestring title text "" (no title) Function2d/3d
TitlePosition[real value, real value]coordinates of the lower left corner of the title  Function2d
TitlePosition[real value,real value,real value]coordinates of the lower left corner of the title  Function3d
TitlePositionXreal value x coordinate of the lower left corner of the title  Function2d/3d
TitlePositionYreal value y coordinate of the lower left corner of the title  Function2d/3d
TitlePositionZreal value z coordinate of the lower left corner of the title  Function3d
TitleFontsee section Fontsfont for the titles sans-serif 11 Function2d/3d

If several functions are drawn simultaneously in one picture, it is useful to display a legend indicating which color is used for which function. See section Legends for further details on legends. Here is a table of the most important attributes determining the form of the legend. The attributes LegendEntry, LegendText, and LegendVisible = TRUE are set automatically by plotfunc2d/plotfunc3d if more than one function is plotted. The property inspector (Viewer, Browser, and Inspector: Interactive Manipulation) allows to reset the legend entry for each function:

attribute name possible values/example meaning default browser entry
LegendEntryTRUE, FALSEadd this function to the legend? TRUEFunction2d/3d
LegendTextstring legend text  Function2d/3d
LegendVisibleTRUE, FALSElegend on/off TRUEScene2d/3d
LegendPlacementTop, Bottomvertical placement BottomScene2d/3d
LegendAlignmentLeft, Center, Righthorizontal alignment CenterScene2d/3d
LegendFontsee section Fontsfont for the legend text sans-serif 8 Scene2d/3d

When singular functions are plotted, it is often useful to request a specific viewing range. Here is a table of the most important attributes for setting viewing ranges. In the interactive object browser, you will find them under CoordinateSystem2d (CS2d) and CoordinateSystem3d (CS3d), respectively:

attribute name possible values/example meaning default browser entry
ViewingBox[xmin..xmax, ymin..ymax], [Automatic, Automatic]viewing range in x and y direction [Automatic, Automatic]CS2d
ViewingBox[xmin..xmax, ymin..ymax, zmin..zmax], [Automatic, Automatic, Automatic]viewing range in x, y, z direction [Automatic, Automatic, Automatic]CS3d
ViewingBoxXRangexmin..xmaxviewing range in x direction Automatic.. AutomaticCS2d/3d
ViewingBoxYRangeymin..ymaxviewing range in y direction Automatic.. AutomaticCS2d/3d
ViewingBoxZRangezmin..zmaxviewing range in z direction Automatic.. AutomaticCS3d
ViewingBoxXMinxmin: real value or Automaticlowest viewing value in x direction AutomaticCS2d/3d
ViewingBoxXMaxxmax: real value or Automatichighest viewing value in x direction AutomaticCS2d/3d
ViewingBoxYMinymin: real value or Automaticlowest viewing value in y direction AutomaticCS2d/3d
ViewingBoxYMaxymax: real value or Automatichighest viewing value in y direction AutomaticCS2d/3d
ViewingBoxZMinzmin: real value or Automaticlowest viewing value in z direction AutomaticCS3d
ViewingBoxZMaxzmax: real value or Automatichighest viewing value in z direction AutomaticCS3d

In contrast to the routines of the plot library, plotfunc2d and plotfunc3d also accept the attributes YMin, YMax, YRange and ZMin, ZMax, ZRange, respectively, as shortcuts for the somewhat clumsy attribute names ViewingBoxYMin etc. E.g.,

plotfunc2d(f(x), x = xmin..xmax, YRange = ymin..ymax)

is equivalent to

plotfunc2d(f(x), x = xmin..xmax,
           ViewingBoxYRange = ymin..ymax)

and

plotfunc3d(f(x, y), x = xmin..xmax, y = ymin..ymax,
           ZRange = zmin..zmax)

is equivalent to

plotfunc3d(f(x, y), x = xmin..xmax, y = ymin..ymax,
           ViewingBoxZRange = zmin..zmax)

Here is a table of the most important attributes for arranging coordinate axes. In the interactive object browser, you will find them under CoordinateSystem2d (CS2d) and CoordinateSystem3d (CS3d), respectively:

attribute name possible values/example meaning default browser entry
AxesAutomatic, Boxed, Frame, Originaxes type AutomaticCS2d/3d
AxesVisibleTRUE, FALSEvisibility of all axes TRUECS2d/3d
XAxisVisibleTRUE, FALSEvisibility of the x axis TRUECS2d/3d
YAxisVisibleTRUE, FALSEvisibility of the y axis TRUECS2d/3d
ZAxisVisibleTRUE, FALSEvisibility of the z axis TRUECS3d
AxesTitles[string, string]titles of the axes (2D) ["x","y"]CS2d
AxesTitles[string, string, string]titles of the axes (3D) ["x","y","z"]CS3d
XAxisTitlestring title of the x axis "x"CS2d/3d
YAxisTitlestring title of the y axis "y"CS2d/3d
ZAxisTitlestring title of the z axis "z"CS3d
AxesTitleAlignmentBegin, Center, Endalignment for all axes titles EndCS2d
AxesTitleAlignmentBegin, Center, Endalignment for all axes titles CenterCS3d
XAxisTitleAlignmentBegin, Center, Endalignment for the x axis title EndCS2d
XAxisTitleAlignmentBegin, Center, Endalignment for the x axis title CenterCS3d
YAxisTitleAlignmentBegin, Center, Endalignment for the y axis title EndCS2d
YAxisTitleAlignmentBegin, Center, Endalignment for the y axis title CenterCS3d
ZAxisTitleAlignmentBegin, Center, Endalignment for the z axis title CenterCS3d
YAxisTitleOrientationVertical, Horizontalorientation of the y axis title HorizontalCS2d
AxesTipsTRUE, FALSEaxes with tips? TRUECS2d/3d
AxesOrigin[real value, real value]crosspoint of the axes (2D) [0, 0]CS2d
AxesOrigin[real value,real value, real value]crosspoint of the axes (3D) [0, 0, 0]CS3d
AxesOriginXreal value x value of AxesOrigin0CS2d/3d
AxesOriginYreal value y value of AxesOrigin0CS2d/3d
AxesOriginZreal value z value of AxesOrigin0CS3d
AxesLineColorRGB color color of the axes RGB::BlackCS2d/3d
AxesLineWidth0.18*unit::mmphysical width of the axes lines 0.18*unit::mmCS2d/3d
AxesInFrontTRUE, FALSEaxes in front of the objects? FALSECS2d
AxesTitleFontsee section Fontsfont for the axes titles sans-serif 10 CS2d/3d

Here is a table of the most important attributes for setting tick marks and tick labels along the axes. In the interactive object browser, you will find them under CoordinateSystem2d (CS2d) and CoordinateSystem3d (CS3d), respectively:

attribute name possible values/example meaning default browser entry
TicksVisibleTRUE, FALSEvisibility of ticks along all axes TRUECS2d/3d
XTicksVisibleTRUE, FALSEvisibility of ticks along the x axis TRUECS2d/3d
YTicksVisibleTRUE, FALSEvisibility of ticks along the y axis TRUECS2d/3d
ZTicksVisibleTRUE, FALSEvisibility of ticks along the z axis TRUECS3d
TicksDistancepositive real value distance between labeled ticks along all axes  CS2d/3d
XTicksDistancepositive real value distance between labeled ticks along the x axis  CS2d/3d
YTicksDistancepositive real value distance between labeled ticks along the y axis  CS2d/3d
ZTicksDistancepositive real value distance between labeled ticks along the z axis  CS3d
TicksAnchorreal value the position of a labeled tick to start with 0CS2d/3d
XTicksAnchorreal value the position of a labeled tick to start with 0CS2d/3d
YTicksAnchorreal value the position of a labeled tick to start with 0CS2d/3d
ZTicksAnchorreal value the position of a labeled tick to start with 0CS3d
TicksNumberNone, Low, Normal, Highnumber of labeled ticks along all axes NormalCS2d/3d
XTicksNumberNone, Low, Normal, Highnumber of labeled ticks along the x axis NormalCS2d/3d
YTicksNumberNone, Low, Normal, Highnumber of labeled ticks along the y axis NormalCS2d/3d
ZTicksNumberNone, Low, Normal, Highnumber of labeled ticks along the z axis NormalCS3d
TicksBetweeninteger ≥ 0number of smaller unlabeled ticks between labeled ticks along all axes 1CS2d/3d
XTicksBetweeninteger ≥ 0number of smaller unlabeled ticks between labeled ticks along the x axis 1CS2d/3d
YTicksBetweeninteger ≥ 0number of smaller unlabeled ticks between labeled ticks along the y axis 1CS2d/3d
ZTicksBetweeninteger ≥ 0number of smaller unlabeled ticks between labeled ticks along the z axis 1CS3d
TicksLabelStyleDiagonal, Horizontal, Shifted, Verticalorientation and style of tick labels along all axes HorizontalCS2d/3d
XTicksLabelStyleDiagonal, Horizontal, Shifted, Verticalorientation and style of tick labels along the x axes HorizontalCS2d/3d
YTicksLabelStyleDiagonal, Horizontal, Shifted, Verticalorientation and style of tick labels along the y axis HorizontalCS2d/3d
ZTicksLabelStyleDiagonal, Horizontal, Shifted, Verticalorientation and style of tick labels along the z axis HorizontalCS3d
TicksAt[tick1, tick2, ...], where tick.i is a real value (the position) or an equation position = "label string" (such as 3.14 = "pi") ticks set by the user, valid for all axes  CS2d/3d
XTicksAtsee TicksAtticks along the x axis set by the user  CS2d/3d
YTicksAtsee TicksAtticks along the y axis set by the user  CS2d/3d
ZTicksAtsee TicksAtticks along the z axis set by the user  CS3d
TicksLength2*unit::mmlength of the tick marks 2*unit::mmCS2d
TicksLabelFontsee section Fontsfont for all axes titles sans-serif 8 CS2d/3d

Coordinate grid lines can be drawn in the background of a graphical scene (corresponding to the rulings of lined paper). They are attached to the tick marks along the axes. There are grid lines attached to the "major" labeled tick marks which are referred to as the "Grid." There are also grid lines associated with the "minor" unlabeled tick marks set be the attribute TicksBetween. These "minor" grid lines are referred to as the "Subgrid." The two kinds of grid lines can be set independently. In the interactive object browser, you will find the following attributes under CoordinateSystem2d (CS2d) and CoordinateSystem3d (CS3d), respectively:

attribute name possible values/example meaning default browser entry
GridVisibleTRUE, FALSEvisibility of "major" grid lines in all directions FALSECS2d/3d
SubgridVisibleTRUE, FALSEvisibility of "minor" grid lines in all directions FALSECS2d/3d
XGridVisibleTRUE, FALSEvisibility of "major" grid lines in x direction FALSECS2d/3d
XSubgridVisibleTRUE, FALSEvisibility of "minor" grid lines in x direction FALSECS2d/3d
YGridVisibleTRUE, FALSEvisibility of "major" grid lines in y direction FALSECS2d/3d
YSubgridVisibleTRUE, FALSEvisibility of "minor" grid lines in y direction FALSECS2d/3d
ZGridVisibleTRUE, FALSEvisibility of "major" grid lines in z direction FALSECS3d
ZSubgridVisibleTRUE, FALSEvisibility of "minor" grid lines in z direction FALSECS3d
GridLineColorRGB color color of all "major" grid lines RGB::Grey75CS2d/3d
SubgridLineColorRGB color color of all "minor" grid lines RGB::GreyCS2d/3d
GridLineWidth0.1*unit::mmwidth of all "major" grid lines 0.1*unit::mmCS2d/3d
SubgridLineWidth0.1*unit::mmwidth of all "minor" grid lines 0.1*unit::mmCS2d/3d
GridLineStyleDashed, Dotted, Soliddrawing style of all "major" grid lines SolidCS2d/3d
SubgridLineStyleDashed, Dotted, Soliddrawing style of all "minor" grid lines SolidCS2d/3d
GridInFrontTRUE, FALSEgrid lines in front of all objects? FALSECS2d

Animations require that plotting ranges x = xmin..xmax (and y = ymin..ymax) are fully specified in plotfunc2d (or plotfunc3d, respectively). Animations are triggered by passing an additional range such as a = amin..amax to plotfunc2d/plotfunc3d. The animation parameter a may turn up in the expression of the functions that are to be plotted as well as in various other places such as the coordinates of titles etc. See section Graphics and Animations for details.

attribute name possible values/example meaning default browser entry
Framesinteger ≥ 0number of frames of the animation 50Function2d/3d
ParameterNamesymbolic name name of the animation parameter  Function2d/3d
ParameterRangeamin..amaxrange of the animation parameter  Function2d/3d
ParameterBeginamin: real value lowest value of the animation parameter  Function2d/3d
ParameterEndamax: real value highest value of the animation parameter  Function2d/3d
TimeRangestart..endphysical time range for the animation 0..10Function2d/3d
TimeBeginstart: real value physical time when the animation begins 0Function2d/3d
TimeEndend: real value physical time when the animation ends 10Function2d/3d
VisibleBeforereal value physical time when the object becomes invisible  Function2d/3d
VisibleAfterreal value physical time when the object becomes visible  Function2d/3d
VisibleFromTorange of real values physical time range when the object is visible  Function2d/3d
VisibleBeforeBeginTRUE, FALSEvisible before animation begins? TRUEFunction2d/3d
VisibleAfterEndTRUE, FALSEvisible after animation ends? TRUEFunction2d/3d

Functions are plotted as polygons consisting of straight line segments between points of the "numerical mesh." The number of points in this numerical mesh are set by various "mesh" attributes:

attribute name possible values/example meaning default browser entry
Meshinteger ≥ 2number of "major" mesh points in x direction. The same as XMesh. 121Function2d
Mesh[integer ≥ 2, integer ≥ 2]number of "major" mesh points in x and y direction. Corresponds to XMesh, YMesh. [25,25]Function3d
Submeshinteger ≥ 0number of "minor" mesh points between the "major" mesh points set by Mesh. The same as XSubmesh. 0Function2d
Submesh[integer ≥ 0, integer ≥ 0]number of "minor" mesh points between the "major" mesh points set by Mesh. Corresponds to XSubmesh, YSubmesh. [0, 0]Function3d
XMeshinteger ≥ 2number of "major" mesh points in the x direction 121Function2d
XMeshinteger ≥ 2number of "major" mesh points in the x direction 25Function3d
XSubmeshinteger ≥ 0number of "minor" mesh points between the "major" mesh points set by XMesh0Function2d/3d
YMeshinteger ≥ 2number of "major" mesh points in the y direction 121Function2d
YMeshinteger ≥ 2number of "major" mesh points in the y direction 25Function3d
YSubmeshinteger ≥ 0number of "minor" mesh points between the "major" mesh points set by YMesh0Function3d
AdaptiveMeshinteger ≥ 0depth of the adaptive mesh 2Function2d
AdaptiveMeshinteger ≥ 0depth of the adaptive mesh 0Function3d

In 2D pictures generated by plotfunc2d, singularities of a function are indicated by vertical lines ("vertical asymptotes"), unless DiscontinuitySearch = FALSE is set. Here is a table with the attributes for setting the style of the vertical asymptotes:

attribute name possible values/example meaning default browser entry
VerticalAsymptotesVisibleTRUE, FALSEvisibility TRUEFunction2d
VerticalAsymptotesColorRGB color color RGB::Grey50Function2d
VerticalAsymptotesStyleDashed, Dotted, Soliddrawing style DashedFunction2d
VerticalAsymptotesWidth0.2*unit::mmphysical width 0.2*unit::mmFunction2d

The colors of the functions plotted by plotfunc2d are chosen automatically. The property inspector (see section Viewer, Browser, and Inspector: Interactive Manipulation) allows to change these attributes:

attribute name possible values/example meaning default browser entry
LinesVisibleTRUE, FALSEvisibility of lines (switch this function on/off) TRUEFunction2d
LineWidth0.2*unit::mmphysical line width 0.2*unit::mmFunction2d
LineColorRGB color color  Function2d
LineColor2RGB color   Function2d
LineStyleDashed, Dotted, Soliddrawing style of line objects SolidFunction2d
LineColorTypeDichromatic, Flat, Functional, Monochrome, Rainbowcolor scheme for lines FlatFunction2d
LineColorFunctionprocedure user defined coloring  Function2d

Setting LinesVisible = FALSE and PointsVisible = TRUE, the functions plotted by plotfunc2d will not be displayed as polygons but as sequences of points. Here is a table of the attributes to set the presentation style of points:

attribute name possible values/example meaning default browser entry
PointsVisibleTRUE, FALSEvisibility of points FALSEFunction2d
PointSize1.5*unit::mmphysical size of points 1.5*unit::mmFunction2d
PointStyleCircles, Crosses, Diamonds, FilledCircles, FilledDiamonds, FilledSquares, Squares, Stars, XCrossespresentation style of points FilledCirclesFunction2d

The colors and surface styles of the functions plotted by plotfunc3d are chosen automatically. The property inspector (see section Viewer, Browser, and Inspector: Interactive Manipulation) allows to the change these attributes:

attribute name possible values/example meaning default browser entry
FilledTRUE, FALSEdisplay as a surface or as a wireframe model? TRUEFunction3d
FillColorRGB or RGBa color main color (for flat coloring)  Function3d
FillColor2RGB or RGBa color secondary color (for Dichromatic and Monochrome coloring)  Function3d
FillColorTypeDichromatic, Flat, Functional, Monochrome, Rainbowcolor scheme DichromaticFunction3d
FillColorFunctionprocedure user defined coloring  Function3d
ShadingSmooth, Flatsmooth or flat shading? SmoothFunction3d
XLinesVisibleTRUE, FALSEvisibility of x parameter lines TRUEFunction3d
YLinesVisibleTRUE, FALSEvisibility of y parameter lines TRUEFunction3d
MeshVisibleTRUE, FALSEvisibility of the internal triangulation FALSEFunction3d
LineWidth0.35*unit::mmphysical line width 0.35*unit::mmFunction3d
LineColorRGB or RGBa color color of parameter lines RGB::Black.[0.25]Function3d

Besides the usual linear plots, logarithmic plots are also possible by choosing an appropriate CoordinateType.

With Scaling = Constrained, the unit box in model coordinates (a square in 2D, a cube in 3D) is displayed as a unit box. With Scaling = Unconstrained, the renderer applies different scaling transformation in the coordinate directions to obtain an optimal fit of the picture in the display window. This, however, may distort a circle to an ellipse. With Scaling = Constrained a 2D circle appears on the screen like a circle, a 3D sphere appears like a sphere.

2D functions are preprocessed by a semi-symbolic search for discontinuities to improve the graphical representation near singularities and to avoid graphical artifacts. If continuous functions are plotted, one may gain some speed up by switching off this search with DiscontinuitySearch = FALSE.

When very time consuming plots are to be created, it may be useful to create the plots in "batch mode." With the attribute OutputFile = filename, the graphical output is not rendered to the screen. An external file with the specified name containing the graphical data is created instead. It may contain xml data that may be viewed later by opening the file with the MuPAD® graphics tool ‘VCam.' Alternatively, bitmap files in various standard bitmap formats such as bmp, jpg etc. can be created that may be viewed by other standard tools. See section Batch Mode for further details.

attribute name possible values/example meaning default browser entry
CoordinateTypeLinLin, LinLog, LogLin, LogLoglinear-linear, linear-logarithmic, logarithmic-linear, log-log LinLinCoord.Sys.2d
CoordinateTypeLinLinLin, ..., LogLogLoglinear-linear-linear, …, log-log-log LinLinLinCoord.Sys.3d
ScalingAutomatic, Constrained, Unconstrainedscaling modeUnconstrainedCoord.Sys.2d/3d
YXRatiopositive real value aspect ratio y : x (only for Scaling = Unconstrained) 1Scene2d/3d
ZXRatiopositive real value aspect ratio z : x (only for Scaling = Unconstrained) 2/3Scene3d
DiscontinuitySearchTRUE, FALSEenable/disable semi-symbolic search for discontinuities TRUEFunction2d
OutputFilestring save the plot data in a file   

Was this topic helpful?