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.

BorderColor, BorderWidth

Color of frame/border around canvas and scenes

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Value Summary

BorderColor, BorderWidthInheritedColor

Graphics Primitives

ObjectsDefault Values
plot::Canvas, plot::Scene2d, plot::Scene3d

BorderColor: RGB::Grey50

BorderWidth: 0


The canvas as well as the scenes in a canvas can be framed by a rectangular border. The width of the border is set by BorderWidth, its color is set by BorderColor.

With the attributes BorderWidth and BorderColor, a canvas or individual scenes can be given a border, similar to an image frame. The border is “switched off” with the default value BorderWidth = 0. Set the border width to some positive value such as BorderWidth = 0.5*unit::mm to make the border visible.

The following picture illustrates the layout of the canvas:

The following picture illustrates the layout of a scene:

The size of a canvas, set by the attributes Width and Height, includes the width of the border set by BorderWidth. The same holds for the scenes.

With BackgroundTransparent = TRUE, transparent scenes (without a background) can be created. The borders do not become transparent!

The scene borders do not react to Layout = Relative. One always has to specify the border width as absolut physical lengths such as BorderWidth = 0.5*unit::mm.

Scenes do not inherit borders from the enclosing canvas. You can set the borders for all scenes simultaneously by specifying them in plot::setDefault as

plot::Scene2d::BorderWidth, plot::Scene2d::BorderColor


plot::Scene3d::BorderWidth, plot::Scene3d::BorderColor,

respectively. Cf. Example 2.


Example 1

Two scenes are displayed side by side. The borders of the canvas and the two scenes are “switched on” by specifying positive values for BorderWidth:

S1 := plot::Scene2d(plot::Function2d(sin(x), x = 0 .. 2*PI),
                    Header = "The sine function",
                    BorderWidth = 0.5*unit::mm):
S2 := plot::Scene2d(plot::Function2d(cos(x), x = 0 .. 2*PI),
                    Header = "The cosine function",
                    BorderWidth = 0.5*unit::mm):
plot(S1, S2, Header = "Trigonometric functions",
     Width = 120*unit::mm, Height = 50*unit::mm,
     BorderWidth = 1.0*unit::mm, BorderColor = RGB::Black,
     Layout = Horizontal):

delete S1, S2:

Example 2

We use plot::setDefault to define new default values for the layout and style parameters BorderWidth, BorderColor, Margin, and BackgroundColor:

  plot::Canvas::BorderWidth = 0.5*unit::mm,
  plot::Canvas::BorderColor = RGB::Black,
  plot::Canvas::Margin = 1.5*unit::mm,
  plot::Canvas::BackgroundColor = RGB::SlateGrey,
  plot::Scene2d::BorderWidth = 0.5*unit::mm,
  plot::Scene2d::BorderColor = RGB::Black,
  plot::Scene2d::Margin = 2*unit::mm,
  plot::Scene2d::BackgroundColor = RGB::Grey

The following canvas contains two scenes. This plot uses the new defaults:

plot(plot::Scene2d(plot::Rectangle(-1..1, -1..1,
                      Filled = TRUE, FillColor = RGB::Red,
                      Header = "Scene 1")),
     plot::Scene2d(plot::Rectangle(-1..1, -1..1,
                      Filled = TRUE, FillColor = RGB::Blue,
                      Header = "Scene 2")),
     Layout = Horizontal, Axes = None,
     Header = "Canvas Header"):

Was this topic helpful?