MATLAB Theming
Style MATLAB charts with color palettes and — for uifigure apps — apply the R2025a Theme API for brand colors, dark mode, and component styling.
When to Use This Skill
Use this skill when:
- Setting
colororder for chart series colors (any context)
- Choosing or importing a color palette for plots
- Organizing brand colors into a reusable struct
- Applying a custom
colormap for continuous data
- Implementing dark mode with
fliplightness() (uifigure)
- Wiring
ThemeChangedFcn to react to OS/user theme changes (uifigure)
- Using
uistyle for conditional formatting in tables/trees (uifigure)
- Importing an external color scheme (Material Design, Adobe Color, Tailwind)
When NOT to Use This Skill
- Choosing chart types or building charts from scratch (use
matlab-build-chart)
- Building a full app layout (use
matlab-build-app — it invokes this skill for theming sub-steps)
- Setting colors on individual plot elements as a one-off (just use the
Color property directly)
- Non-MATLAB styling (CSS, HTML themes for web apps)
Critical Rules
Universal (all contexts)
- MUST centralize brand/palette colors in a struct — never scatter RGB values
- ALWAYS use
colororder() for categorical chart series colors
- ALWAYS use
colormap() for continuous scalar-mapped colors
- NEVER confuse
colororder (categorical series) with colormap (continuous gradient)
Additional rules for uifigure apps (R2025a Theme API)
- MUST use R2025a Theme API — do NOT manually set figure background or standard component colors
- MUST use
fliplightness() to derive dark variants unless explicitly designing custom dark colors
- NEVER set a component's color explicitly unless branding requires it — breaks theme adaptation
- ALWAYS use the semantic token vocabulary defined below for cross-path consistency
Semantic Token Vocabulary
Both MATLAB and web implementations map to these common tokens. When importing an external color scheme, map its colors to these tokens once.
| Token |
Purpose |
MATLAB (struct field) |
Web (CSS variable) |
primary |
Brand/action color (buttons, links, active states) |
theme.primary |
--accent |
onPrimary |
Text/icon on primary background |
theme.onPrimary |
--accent-text |
secondary |
Secondary brand color (less prominent actions) |
theme.secondary |
--secondary |
error |
Error/destructive state |
theme.error |
--error |
success |
Success/confirmation state |
theme.success |
--success |
warning |
Warning/caution state |
theme.warning |
--warning |
border |
Custom borders and dividers |
theme.border |
--border |
plotColors |
Chart series colors (Nx3 RGB matrix) |
theme.plotColors |
N/A (use chart library config) |
MATLAB note: Surface/text colors (--bg-primary, --text-primary in CSS) are NOT in the MATLAB theme struct. The R2025a Theme API handles those automatically. Only define brand/custom colors.
Quick Start
Color palettes for any figure
colors = [0 0.447 0.741; 0.85 0.33 0.10; 0.93 0.69 0.13; ...
0.49 0.18 0.56; 0.47 0.67 0.19; 0.30 0.75 0.93];
colororder(ax, colors);
% All series in this axes now cycle through these colors
Theme struct for uifigure apps (R2025a)
function theme = createTheme(mode)
arguments
mode string {mustBeMember(mode, ["light", "dark"])} = "light"
end
theme.primary = [0 0.447 0.741]; % MATLAB blue
theme.onPrimary = [1 1 1];
theme.error = [0.83 0.18 0.18];
theme.success = [0.22 0.56 0.24];
theme.border = [0.88 0.88 0.88];
theme.plotColors = [0 0.447 0.741; 0.85 0.33 0.10; 0.93 0.69 0.13; ...
0.49 0.18 0.56; 0.47 0.67 0.19; 0.30 0.75 0.93; 0.64 0.08 0.18];
if mode == "dark"
theme.primary = fliplightness(theme.primary);
theme.plotColors = fliplightness(theme.plotColors);
end
end
Wiring to a figure:
fig.ThemeChangedFcn = @(src, ~) applyTheme(src, ax);
function applyTheme(fig, ax)
theme = createTheme(fig.Theme.BaseColorStyle);
colororder(ax, theme.plotColors);
end
Light/Dark Strategy
- Don't set figure background, standard component bg/text — Theme API handles it automatically
- Do set brand colors (primary buttons, accent labels, status indicators) via theme struct
- Use
ThemeChangedFcn to swap brand colors when OS/user toggles dark mode
- Use
fliplightness() to auto-derive dark brand colors from light definitions
- Leave
ColorMode = "auto" on components wherever possible
What breaks automatic theming — setting any color explicitly switches ColorMode to "manual":
btn.BackgroundColor = [0.2 0.4 0.8]; % Now manual — won't adapt to theme
btn.BackgroundColorMode = "auto"; % Restore theme control
Color Types in MATLAB
| Type |
API |
When to use |
| Component colors |
btn.BackgroundColor, lbl.FontColor |
UI element branding |
| Series colors |
colororder(colors) or colororder("palette") |
Multiple lines/bars/scatter in one axes |
| Continuous colors |
colormap(map) |
Heatmaps, surfaces, contours, images |
| Cell/row styling |
uistyle + addStyle |
Conditional formatting in tables/trees |
colororder = categorical (series A, B, C get distinct colors)
colormap = continuous (scalar values mapped to gradient)
- Don't confuse them — they serve different purposes
Importing External Color Schemes
Workflow
- Pick a scheme from Material Design, Adobe Color, Tailwind, etc.
- Extract 5-7 key colors: primary, secondary, error, success, warning, border + 5-7 chart series colors
- Convert hex to [R G B] normalized 0-1:
rgb = sscanf(hex(2:end), '%2x', 3)' / 255
- Map to theme struct fields:
theme.primary, theme.secondary, etc.
- Test both modes: verify
fliplightness() produces acceptable dark variants; override manually if not
- Apply via
applyBrandColors: the function reads the struct and sets tagged components
See references/external-schemes.md for complete Material Design, Adobe Color, and Tailwind import examples.
Implementation Checklist
Styling
Troubleshooting
| Problem |
Cause |
Fix |
| Component doesn't change with dark mode |
Color set explicitly |
Remove explicit color or set BackgroundColorMode = "auto" |
fliplightness not found |
MATLAB < R2025a |
Upgrade or define manual dark colors |
| Chart colors don't update on theme switch |
colororder not re-applied |
Add colororder(ax, theme.plotColors) to theme handler |
findall returns empty |
Tag not set or misspelled |
Verify Tag property matches exactly |
References
| Topic |
File |
Description |
| Theme API |
references/theme-api.md |
R2025a lock/detect/react, auto vs manual theming |
| Component colors |
references/component-colors.md |
Color properties table + uistyle for tables/trees |
| External schemes |
references/external-schemes.md |
Material Design, Adobe Color, Tailwind import workflows |
Copyright 2026 The MathWorks, Inc.
1---2name: matlab-theming3license: MathWorks BSD-3-Clause4metadata:5 source: https://skillmd.com/skills/stanfish06/matlab-theming6 author: MathWorks7 version: "1.0"8description: >9 Style MATLAB charts and figures. colororder palettes for chart series colors,10 colormap selection, brand color organization, and the R2025a Theme API for uifigure11 apps (dark mode with fliplightness, ThemeChangedFcn, uistyle, component colors).12 Use when customizing chart colors, applying a color palette, organizing brand colors,13 implementing dark mode, or importing an external color scheme. Triggers: theme,14 dark mode, brand colors, colororder, colormap, palette, fliplightness, color scheme,15 styling, chart colors.16allowed-tools:17 - Read18 - Write19 - Edit20 - Bash21---2223# MATLAB Theming2425Style MATLAB charts with color palettes and — for uifigure apps — apply the R2025a Theme API for brand colors, dark mode, and component styling.2627## When to Use This Skill2829Use this skill when:30- Setting `colororder` for chart series colors (any context)31- Choosing or importing a color palette for plots32- Organizing brand colors into a reusable struct33- Applying a custom `colormap` for continuous data34- Implementing dark mode with `fliplightness()` (uifigure)35- Wiring `ThemeChangedFcn` to react to OS/user theme changes (uifigure)36- Using `uistyle` for conditional formatting in tables/trees (uifigure)37- Importing an external color scheme (Material Design, Adobe Color, Tailwind)3839## When NOT to Use This Skill4041- Choosing chart types or building charts from scratch (use `matlab-build-chart`)42- Building a full app layout (use `matlab-build-app` — it invokes this skill for theming sub-steps)43- Setting colors on individual plot elements as a one-off (just use the `Color` property directly)44- Non-MATLAB styling (CSS, HTML themes for web apps)4546## Critical Rules4748### Universal (all contexts)4950- MUST centralize brand/palette colors in a struct — never scatter RGB values51- ALWAYS use `colororder()` for categorical chart series colors52- ALWAYS use `colormap()` for continuous scalar-mapped colors53- NEVER confuse `colororder` (categorical series) with `colormap` (continuous gradient)5455### Additional rules for uifigure apps (R2025a Theme API)5657- MUST use R2025a Theme API — do NOT manually set figure background or standard component colors58- MUST use `fliplightness()` to derive dark variants unless explicitly designing custom dark colors59- NEVER set a component's color explicitly unless branding requires it — breaks theme adaptation60- ALWAYS use the semantic token vocabulary defined below for cross-path consistency6162## Semantic Token Vocabulary6364Both MATLAB and web implementations map to these common tokens. When importing an external color scheme, map its colors to these tokens once.6566| Token | Purpose | MATLAB (struct field) | Web (CSS variable) |67|---|---|---|---|68| `primary` | Brand/action color (buttons, links, active states) | `theme.primary` | `--accent` |69| `onPrimary` | Text/icon on primary background | `theme.onPrimary` | `--accent-text` |70| `secondary` | Secondary brand color (less prominent actions) | `theme.secondary` | `--secondary` |71| `error` | Error/destructive state | `theme.error` | `--error` |72| `success` | Success/confirmation state | `theme.success` | `--success` |73| `warning` | Warning/caution state | `theme.warning` | `--warning` |74| `border` | Custom borders and dividers | `theme.border` | `--border` |75| `plotColors` | Chart series colors (Nx3 RGB matrix) | `theme.plotColors` | N/A (use chart library config) |7677**MATLAB note:** Surface/text colors (`--bg-primary`, `--text-primary` in CSS) are NOT in the MATLAB theme struct. The R2025a Theme API handles those automatically. Only define brand/custom colors.7879## Quick Start8081### Color palettes for any figure8283```matlab84colors = [0 0.447 0.741; 0.85 0.33 0.10; 0.93 0.69 0.13; ...85 0.49 0.18 0.56; 0.47 0.67 0.19; 0.30 0.75 0.93];86colororder(ax, colors);87% All series in this axes now cycle through these colors88```8990### Theme struct for uifigure apps (R2025a)9192```matlab93function theme = createTheme(mode)94 arguments95 mode string {mustBeMember(mode, ["light", "dark"])} = "light"96 end97 theme.primary = [0 0.447 0.741]; % MATLAB blue98 theme.onPrimary = [1 1 1];99 theme.error = [0.83 0.18 0.18];100 theme.success = [0.22 0.56 0.24];101 theme.border = [0.88 0.88 0.88];102 theme.plotColors = [0 0.447 0.741; 0.85 0.33 0.10; 0.93 0.69 0.13; ...103 0.49 0.18 0.56; 0.47 0.67 0.19; 0.30 0.75 0.93; 0.64 0.08 0.18];104 if mode == "dark"105 theme.primary = fliplightness(theme.primary);106 theme.plotColors = fliplightness(theme.plotColors);107 end108end109```110111Wiring to a figure:112113```matlab114fig.ThemeChangedFcn = @(src, ~) applyTheme(src, ax);115116function applyTheme(fig, ax)117 theme = createTheme(fig.Theme.BaseColorStyle);118 colororder(ax, theme.plotColors);119end120```121122## Light/Dark Strategy1231241. **Don't set** figure background, standard component bg/text — Theme API handles it automatically1252. **Do set** brand colors (primary buttons, accent labels, status indicators) via theme struct1263. Use `ThemeChangedFcn` to swap brand colors when OS/user toggles dark mode1274. Use `fliplightness()` to auto-derive dark brand colors from light definitions1285. Leave `ColorMode = "auto"` on components wherever possible129130What breaks automatic theming — setting any color explicitly switches `ColorMode` to `"manual"`:131132```matlab133btn.BackgroundColor = [0.2 0.4 0.8]; % Now manual — won't adapt to theme134btn.BackgroundColorMode = "auto"; % Restore theme control135```136137## Color Types in MATLAB138139| Type | API | When to use |140|---|---|---|141| **Component colors** | `btn.BackgroundColor`, `lbl.FontColor` | UI element branding |142| **Series colors** | `colororder(colors)` or `colororder("palette")` | Multiple lines/bars/scatter in one axes |143| **Continuous colors** | `colormap(map)` | Heatmaps, surfaces, contours, images |144| **Cell/row styling** | `uistyle` + `addStyle` | Conditional formatting in tables/trees |145146- `colororder` = categorical (series A, B, C get distinct colors)147- `colormap` = continuous (scalar values mapped to gradient)148- Don't confuse them — they serve different purposes149150## Importing External Color Schemes151152### Workflow1531541. **Pick a scheme** from Material Design, Adobe Color, Tailwind, etc.1552. **Extract 5-7 key colors**: primary, secondary, error, success, warning, border + 5-7 chart series colors1563. **Convert hex to [R G B]** normalized 0-1: `rgb = sscanf(hex(2:end), '%2x', 3)' / 255`1574. **Map to theme struct fields**: `theme.primary`, `theme.secondary`, etc.1585. **Test both modes**: verify `fliplightness()` produces acceptable dark variants; override manually if not1596. **Apply via `applyBrandColors`**: the function reads the struct and sets tagged components160161See `references/external-schemes.md` for complete Material Design, Adobe Color, and Tailwind import examples.162163## Implementation Checklist164165### Styling166- [ ] Brand colors centralized in `createTheme` struct167- [ ] `fliplightness()` used for dark variants168- [ ] Branded components tagged for `findall` lookup169- [ ] `ThemeChangedFcn` wired to re-apply brand colors170- [ ] `colororder` set from `theme.plotColors`171- [ ] No explicit colors on auto-themed components172173## Troubleshooting174175| Problem | Cause | Fix |176|---|---|---|177| Component doesn't change with dark mode | Color set explicitly | Remove explicit color or set `BackgroundColorMode = "auto"` |178| `fliplightness` not found | MATLAB < R2025a | Upgrade or define manual dark colors |179| Chart colors don't update on theme switch | `colororder` not re-applied | Add `colororder(ax, theme.plotColors)` to theme handler |180| `findall` returns empty | Tag not set or misspelled | Verify `Tag` property matches exactly |181182## References183184| Topic | File | Description |185|-------|------|-------------|186| Theme API | `references/theme-api.md` | R2025a lock/detect/react, auto vs manual theming |187| Component colors | `references/component-colors.md` | Color properties table + uistyle for tables/trees |188| External schemes | `references/external-schemes.md` | Material Design, Adobe Color, Tailwind import workflows |189190----191192Copyright 2026 The MathWorks, Inc.193194----