FillColor, FillColor2

Color of areas and surfaces

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.

Value Summary

FillColor, FillColor2InheritedColor


FillColor determines the color used to fill all types of areas and surfaces. FillColor2 is used for color blends. FillColors is used for objects that need more than one color.

2D objects that have a notion of “area” and 3D objects that have a surface support FillColor to determine the primary color to show objects in. If FillColorType is set to Dichromatic, FillColor2 sets the second color to blend to.

Functions and primitives displaying more than one object, such as plot::Bars2d, use FillColors for a list of colors used cyclically.


Example 1

By default, plot::Hatch objects are hatched in RGB ::Red, the same color used by default for plot::Function2d:

f := plot::Function2d(cos(2*x)+cos(x), x=-PI..PI):
h := plot::Hatch(f):
plot(h, f)

To change the color of the hatch, simply set the "FillColor"-slot to some other value:

h::FillColor := RGB::Grey:
plot(h, f)

Example 2

The default setting for a surface is to have a height-dependent coloring with a linear blend from FillColor to FillColor2:

s := plot::Surface([cos(2*u+v), sin(u+2*v), sin(u+v)],
                   u = 0..2*PI, v = 0..2*PI,
                   ULinesVisible = FALSE, 
                   VLinesVisible = FALSE):

These colors can be manipulated in the usual way. As an example, we set the transition to a monochrome transition from opaque to transparent:

s::FillColor  := RGB::Green:
s::FillColor2 := s::FillColor . [0.0]:

Example 3

Using a utility function randrange that returns random ranges in [0, 1], we can plot random rectangles with random colors:

randrange := () -> _range(op(sort([frandom(), frandom()]))):
plot(plot::Rectangle(randrange(), randrange(),
                     LinesVisible = FALSE,
                     Filled = TRUE, FillPattern = Solid,
                     FillColor = [frandom(), frandom(), frandom()])
     AxesVisible = FALSE)

See Also

MuPAD Functions