Main Content

theme

Set or get graphics theme

Since R2025a

    Description

    Set Theme

    theme(newtheme) sets the theme of the current figure to the specified new theme, which can be "light", "dark", "auto", or a GraphicsTheme object. Parentheses are optional for this syntax when you specify one of the theme names. For example, theme light is the same as theme("light").

    Calling this function sets the Theme and ThemeMode properties of the figure.

    example

    theme(fig,newtheme) sets the theme of the specified figure.

    gt = theme(___) sets the theme and returns it as a GraphicsTheme object.

    example

    Get Theme

    gt = theme returns the theme of the current figure as a GraphicsTheme object.

    gt = theme(fig) returns the theme of the specified figure.

    Examples

    collapse all

    Create a figure and set its theme to "dark" by calling the theme function and returning the GraphicsTheme object as gt. Then create a bar chart in the figure.

    fig = figure;
    gt = theme(fig,"dark");
    bar([1 2 3 4; 5 6 7 8])

    Figure contains an axes object. The axes object contains 4 objects of type bar.

    Change the theme to "light".

    theme(fig,"light")

    Figure contains an axes object. The axes object contains 4 objects of type bar.

    Use the GraphicsTheme object, gt, to set the theme.

    theme(fig,gt)

    Figure contains an axes object. The axes object contains 4 objects of type bar.

    Input Arguments

    collapse all

    New theme, specified as "light", "dark", "auto", or a GraphicsTheme object.

    Target figure, specified as a Figure object or an array of Figure objects.

    Output Arguments

    collapse all

    Graphics theme object with these properties.

    PropertyDescription

    Name

    Short description of the theme, returned as 'Light Theme' or 'Dark Theme'.

    BaseColorStyle

    Basic color style of the theme, returned as 'light' or 'dark'. This property indicates the overall lightness or darkness of the theme. Query this property when deciding on a color palette for your chart or when writing a ThemeChangedFcn callback.

    Version History

    Introduced in R2025a