Documentation Center

  • Trial Software
  • Product Updates

Specify Block Diagram Colors

Set Block Diagram Colors Interactively

You can specify the foreground and background colors of any block or annotation in a diagram, as well as the background color of the diagram.

Type of ColorHow to Set

Block diagram background

Select Diagram > Format > Canvas Color.

Block or annotation background

  1. Select the blocks and annotations.

  2. Select Diagram > Format > Background Color

Block or annotation foreground

  1. Select the blocks and annotations.

  2. Select Diagram > Format > Foreground Color

In all cases, you see a menu of color choices. Choose the desired color from the menu. If you select a color other than Custom, the background or foreground color of the diagram or diagram element changes to the selected color.

Platform Differences for Custom Colors

On Mac platforms, choosing Custom invokes the Mac color picker interface. Use the color picker to choose and define custom colors.

On Windows® and Linux® platforms, use the Simulink® interface, as described in:

Choose a Custom Color

If you choose Custom, and there are no custom colors already defined, Simulink displays the Choose Custom Color dialog box.

If you choose Custom, and there are custom colors already defined, Simulink displays the Select Color dialog box.

The Select Color dialog box displays a palette of basic colors and a palette of already defined custom colors. To choose a color from either palette, click the color and then click OK.

Define a Custom Color

To define the first custom color, in the Choose Custom Color dialog box, click the Define Custom Colors button.

The dialog box expands to display the Select Color dialog box. To define a custom color:

  1. Specify the color using one of these approaches:

    • Enter the red, green, and blue components of the color as values between 0 (darkest) and 255 (brightest).

    • Enter hue, saturation, and luminescence components of the color as values in the range 0 to 255.

    • Move the hue-saturation cursor to select the hue and saturation of the desired color and the luminescence cursor to select the luminescence of the desired color.

  2. Adjust the values until the color in the box to the right of the custom colors palette is the custom color that you want.

  3. Click the Add to Custom Colors button.

To replace an existing custom color, select the custom color in the custom color palette before defining the new custom color.

Specify Colors Programmatically

You can use the set_param command at the MATLAB® command line or in a MATLAB program to set parameters that determine the background color of a diagram and the background color and foreground color of diagram elements. The following table summarizes the parameters that control block diagram colors.

ParameterDetermines

Block diagram background

ScreenColor

Block and annotation background

BackgroundColor

Block and annotation foreground

ForegroundColor

Set the color parameter to either a named color or an RGB value.

  • Named color: 'black', 'white', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'gray', 'lightBlue', 'orange', 'darkGreen'

  • RGB value: '[r,g,b]'

    where r, g, and b are the red, green, and blue components of the color normalized to the range 0.0 to 1.0.

For example, the following command sets the background color of the currently selected system or subsystem to a light green color:

set_param(gcs, 'ScreenColor', '[0.3, 0.9, 0.5]')
Was this topic helpful?