MuPAD® notebooks will be removed in a future release. 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.

The most prominent plot attribute, available for all primitives, is Color. The MuPAD® plot library knows 3 different types of colors:

The primitives also accept the attribute Color as a shortcut for any one of these colors. Depending on the primitive, either PointColor, LineColor, or FillColor is set with the Color attribute.

RGB Colors

MuPAD uses the RGB color model, i.e., colors are specified by lists [r, g, b] of red, green, and blue values between 0 and 1. Black and white correspond to[0, 0, 0] and [1, 1, 1], respectively. The library RGB contains numerous color names with corresponding RGB values:

RGB::Black, RGB::White, RGB::Red, RGB::SkyBlue

You may list all color names available in the RGB library via info(RGB). Alternatively, there is the command RGB::ColorNames() returning a complete list of names, optionally filtered. For example, let us list all the colors whose names contain “Red”:


To get them displayed, use


After loading the color library via use(RGB), you can use the color names in the short form Black, White, IndianRed etc.

In MuPAD, the color of all graphic elements can either be specified by RGB or RGBa values.

RGBa color values consist of lists [r, g, b, a] containing a fourth entry: the “opacity” value a between 0 and 1. For a = 0, a surface patch painted with this RGBa color is fully transparent (i.e., invisible). For a = 1, the surface patch is opaque, i.e., it hides plot objects that are behind it. For 0 < a < 1, the surface patch is semitransparent, i.e., plot objects behind it “shine through.”

RGBa color values can be constructed easily via the RGB library. One only has to append a fourth entry to the [r, g, b] lists provided by the color names. The easiest way to do this is to append the list [a] to the RGB list via the concatenation operator ‘.’. We create a semitransparent ‘grey’:


The following command plots a highly transparent red box, containing a somewhat less transparent green box with an opaque blue box inside:

  plot::Box(-3..3, -3..3, -3..3, FillColor = RGB::Red.[0.2]),
  plot::Box(-2..2, -2..2, -2..2, FillColor = RGB::Green.[0.3]),
  plot::Box(-1..1, -1..1, -1..1, FillColor = RGB::Blue),
  LinesVisible = TRUE, LineColor = RGB::Black,
  Scaling = Constrained

In the following example, we plot points randomly distributed with random colors and random translucencies:

plot(plot::PointList2d([[frandom() $ i = 1..2, 
                         [frandom() $ i = 1..4]] 
                       $ i = 1..300],
     Axes=None, Scaling=Constrained)

HSV Colors

Apart from the RGB model, there are various other popular color formats used in computer graphics. One is the HSV model (Hue, Saturation, Value). The RGB library provides the routines RGB::fromHSV and RGB::toHSV to convert HSV colors to RGB colors and vice versa:

hsv := RGB::toHSV(RGB::Orange)

RGB::fromHSV(hsv) = RGB::Orange

With the RGB::fromHSV utility, all colors in a MuPAD plot can be specified easily as HSV colors. For example, the color ‘violet’ is given by the HSV values [290, 0.4, 0.6], whereas ‘dark green’ is given by the HSV specification [120, 1, 0.4]. Hence, a semitransparent violet sphere intersected by an opaque dark green plane may be specified as follows:

plot(plot::Sphere(1, [0, 0, 0], 
                  Color = RGB::fromHSV([290, 0.4, 0.6]).[0.5]),
     plot::Surface([x, y, 0.5], x = -1..1, y = -1..1, 
                   Mesh = [2, 2],
                   Color = RGB::fromHSV([120, 1, 0.4]))