Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Attributes

The plot library provides for more than 400 attributes for fine-tuning of the graphical output. Because of this large number, the attributes are grouped into various categories in the object browser (see section Viewer, Browser, and Inspector: Interactive Manipulation) and the documentation:

categorymeaning
Animation parameters relevant for animations
Annotation footer, header, titles, and legends
Axes axes style and axes titles
Cameras cameras in 3D
Lights lights in 3D
Calculation numerical evaluation (mesh parameters)
Definition parameters that change the object itself
Grid Lines grid lines in the background (rulings)
Layout layout parameters for canvas and scenes
Style parameters that do not change the objects but their presentation (visibility, color, line width, point size etc.)
Arrow Style style parameters for arrows
Line Style style parameters for line objects
Point Style style parameters for point objects
Surface Style style parameters for surface objects in 3D and filled areas in 2D
Tick Marks axes tick marks: style and labels

On the help page for each primitive, there is a complete list of all attributes the primitive reacts to. Clicking on an attribute, you are lead to the help page for this attribute which provides for all the necessary information concerning its semantics and admissible values. The examples on the help page demonstrate the typical use of the attribute.

Default Values

Most attributes have a default value that is used if no value is specified explicitly. As an example, we consider the attribute LinesVisible that is used by several primitives such as plot::Box, plot::Circle2d, plot::Cone, plot::Curve2d, plot::Raster etc. Although they all use the same attribute named LinesVisible, its default value differs among the different primitive types. The specific defaults are accessible by the slots plot::Box::LinesVisible, plot::Circle2d::LinesVisible etc.:

plot::getDefault(plot::Box::LinesVisible),
plot::getDefault(plot::Circle2d::LinesVisible),
plot::getDefault(plot::Cone::LinesVisible),
plot::getDefault(plot::Raster::LinesVisible)

If any of the default values provided by the MuPAD® system do not seem appropriate for your applications, change these defaults via plot::setDefault:

plot::setDefault(plot::Box::LinesVisible = FALSE)

(The return value is the previously valid default value.) Several defaults can be changed simultaneously:

plot::setDefault(plot::Box::LinesVisible = FALSE,
                 plot::Circle2d::LinesVisible = FALSE,
                 plot::Circle2d::Filled = TRUE)

plot::getDefault(plot::Box::LinesVisible)

Inheritance of Attributes

The setting of default values for attributes is quite sophisticated. Assume that you have two scenes that are to be displayed in one single canvas. Both scenes consist of 51 graphical points, each:

points1 := plot::Point2d(i/50*PI, sin(i/50*PI)) $ i = 0..50:
points2 := plot::Point2d(i/50*PI, cos(i/50*PI)) $ i = 0..50:
S1 := plot::Scene2d(points1):
S2 := plot::Scene2d(points2):
plot(S1, S2):

If we wish to color all points in both scenes red, we can set a default for the point color in the plot command:

plot(S1, S2, PointColor = RGB::Red):

If we wish to color all points in the first scene red and all points in the second scene blue, we can give each of the points the desired color in the generating call to plot::Point2d. Alternatively, we can set separate defaults for the point color inside the scenes:

S1 := plot::Scene2d(points1, PointColor = RGB::Red):
S2 := plot::Scene2d(points2, PointColor = RGB::Blue):
plot(S1, S2):

Here is the general rule for setting defaults inside a graphical tree (see The Full Picture: Graphical Trees):

    Note:   When an attribute is specified in a node of the graphical tree, the specified value serves as the default value for the attribute for all primitives that exist in the sub-tree starting from that node.

The default value can be overwritten by another value at each node further down in the sub-tree (for example, finally, by a specific value in the primitives). In the following call, the default color ‘red' is set in the canvas. This value is accepted and used in the first scene. The second scene sets the default color ‘blue' overriding the default value ‘red' set in the canvas. Additionally, there is an extra point with a color set explicitly to ‘black.' This point ignores the defaults set further up in the tree hierarchy:

extrapoint := plot::Point2d(1.4, 0.5, PointSize = 3*unit::mm,
                            PointColor = RGB::Black):
S1 := plot::Scene2d(points1, extrapoint):
S2 := plot::Scene2d(points2, extrapoint, 
                    PointColor = RGB::Blue):
plot(plot::Canvas(S1, S2, PointColor = RGB::Red)):

The following call generates the same result. Note that the plot command automatically creates a canvas object and passes the attribute PointColor = RGB::Red to the canvas:

plot(S1, S2, PointColor = RGB::Red):

We note that there are different primitives that react to the same attribute. We used LinesVisible in the previous section to demonstrate this fact. One of the rules for inheriting attributes in a graphical tree is:

    Note:   If an attribute such as LinesVisible = TRUE is specified in some node of the graphical tree, all primitives below this node that react to this attribute use the specified value as the default value.

    If a type specific attribute such as plot::Circle2d::LinesVisible = TRUE is specified, the new default value is valid only for primitives of that specific type.

In the following example, we consider 100 randomly placed circles with a rectangle indicating the area into which all circle centers are placed:

rectangle := plot::Rectangle(0..1, 0 ..1):
circles := plot::Circle2d(0.05, [frandom(), frandom()]) 
                                                  $ i = 1..100:
plot(rectangle, circles, Axes = Frame):

We wish to turn the circles into filled circles by Filled = TRUE, LinesVisible = FALSE:

plot(rectangle, circles, 
     Filled = TRUE, FillPattern = Solid, 
     LinesVisible = FALSE, Axes = Frame):

This is not quite what we wanted: Not only the circles, but also the rectangle reacts to the attributes Filled, FillPattern, and LinesVisible. The following command restricts these attributes to the circles:

plot(rectangle, circles, 
     plot::Circle2d::Filled = TRUE, 
     plot::Circle2d::FillPattern = Solid, 
     plot::Circle2d::LinesVisible = FALSE,
     Axes = Frame):

Primitives Requesting Special Scene Attributes: "Hints"

The default values for the attributes are chosen in such a way that they produce reasonable pictures in "typical" plot commands. For example, the default axes type in 3D scenes is Axes = Boxed because this is the most appropriate axes type in the majority of 3D plots:

plot::getDefault(plot::CoordinateSystem3d::Axes)

However, there are exceptions. E.g., a plot containing a 3D pie chart should probably have no axes at all. Since it is not desirable to use Axes = None as the default setting for all plots, exceptional primitives such as plot::Piechart3d are given a chance to override the default axes automatically. In a pie chart plot, no axes are used by default:

plot(plot::Piechart3d([20, 30, 10, 7, 20, 13],
             Titles = [1 = "20%", 2 = "30%", 3 = "10%",
                       4 =  "7%", 5 = "20%", 6 = "13%"])):

Note that Axes is a scene attribute that cannot be processed by pie chart objects directly. Hence, a separate mechanism for requesting special scene attributes by primitives is implemented: so-called "hints."

A "hint" is an attribute of one of the superordinate nodes in the graphical tree, for example, an attribute of a coordinate system, a scene or the canvas. The help pages of the primitives give information on what "hints" are sent by the primitive. If several primitives send conflicting hints, the first "hint" is used.

"Hints" are implemented internally and cannot be switched off by the user. Note, however, that the "hints" concept only concerns default values for attributes. You can always specify the attribute explicitly if you think that a default value or a "hint" is not appropriate. E.g., we explicitly request Axes = Boxed in the following call:

plot(plot::Piechart3d([20, 30, 10, 7, 20, 13],
             Titles = [1 = "20%", 2 = "30%", 3 = "10%",
                       4 =  "7%", 5 = "20%", 6 = "13%"]),
     Axes = Boxed):

The Help Pages of Attributes

We have a brief look at a typical help page for a plot attribute to explain the information provided there:

The item "Acceptable Values" states the type of the number n that is admissible when passing the attributes UMesh = n, VMesh = n etc.

The item "Attribute type: inherited" states that these attributes may not only be specified in the generating call of graphical primitives. They can also be specified at higher nodes of a graphical tree to be inherited to the primitives in the corresponding sub-tree (see section Inheritance of Attributes).

The sections "Object types reacting to UMesh" etc. provide complete listings of all primitives reacting to the attribute(s) together with the specific default values.

The "Details" section gives further information on the semantics of the attribute(s). Finally, there are "Examples" of plot commands using the described attribute(s).

Was this topic helpful?