Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/matlab-app-building/matlab-build-chart

matlab-build-chart

Verified

Create and customize MATLAB charts and plots. Plot types (line, scatter, bar, histogram, heatmap, surface), axes configuration, annotations, data tips, interactive plots, animation, multiple axes with tiledlayout, colororder, and performance optimization. Works for standalone figures, Live Scripts, and uifigure apps. Use when plotting data, customizing axes, adding annotations or interactivity, animating charts, or arranging multiple axes. Triggers: plot, chart, graph, axes, uiaxes, annotation, data tips, animation, tiledlayout, colororder, heatmap, scatter, figure, visualization, export.

FileKindSize
SKILL.mdskill md13.7 KB
manifest.yamlconfig523 B
references/animation.mdexecutablescript2.1 KB
references/annotations.mdexecutablescript1.2 KB
references/axes-config.mdexecutablescript2.2 KB
references/chart-palettes.mdexecutablescript1.8 KB
references/data-tips.mdexecutablescript976 B
references/interactive-plots.mdexecutablescript2.9 KB
references/multiple-axes.mdexecutablescript2.4 KB
references/performance.mdexecutablescript4.0 KB
references/plot-types.mdexecutablescript2.4 KB

references/multiple-axes.md

View on GitHub
# Multiple Axes

Do NOT use `subplot()` — it does not work reliably in uifigure. Two alternatives:

## Option 1: tiledlayout + nexttile (pure plot grids)

```matlab
fig = uifigure;
tl = tiledlayout(fig, 2, 2);
tl.TileSpacing = 'compact';
tl.Padding = 'compact';

ax1 = nexttile(tl);
plot(ax1, x, y1);
title(ax1, 'Signal 1');

ax2 = nexttile(tl);
plot(ax2, x, y2);
title(ax2, 'Signal 2');

% Spanning multiple tiles
ax3 = nexttile(tl, [1 2]);        % span 1 row, 2 columns
plot(ax3, x, y3);
title(ax3, 'Combined');
```

## Arrangement Options

| Syntax | Behavior |
|---|---|
| `tiledlayout(fig, m, n)` | Fixed m-by-n grid |
| `tiledlayout(fig, "flow")` | Auto-reflows tiles to fit figure size (~4:3 aspect) |
| `tiledlayout(fig, "vertical")` | Stack tiles top-to-bottom (R2023a+) |
| `tiledlayout(fig, "horizontal")` | Stack tiles left-to-right (R2023a+) |

**TileSpacing / Padding values:** `"loose"` (default), `"compact"`, `"tight"`, `"none"`

## Shared Titles, Labels, and Linked Axes

```matlab
tl = tiledlayout(fig, 2, 1, 'TileSpacing', 'compact');
ax1 = nexttile(tl); plot(ax1, x, y1);
ax2 = nexttile(tl); plot(ax2, x, y2);

% Shared title and axis labels on the layout object
title(tl, 'Experiment Results');
xlabel(tl, 'Time (s)');
ylabel(tl, 'Amplitude');

% Synchronized zoom/pan across axes
linkaxes([ax1, ax2], 'x');
```

## Shared Colorbar or Legend in Peripheral Tile

```matlab
ax1 = nexttile(tl); imagesc(ax1, data1);
ax2 = nexttile(tl); imagesc(ax2, data2);
cb = colorbar(ax2);
cb.Layout.Tile = 'east';          % shared colorbar outside grid
```

## Manual Tile Positioning

```matlab
tl = tiledlayout(fig, 'flow');
ax = nexttile(tl);
ax.Layout.Tile = 4;               % place in tile 4
ax.Layout.TileSpan = [2 3];       % span 2 rows, 3 columns
```

## Option 2: Multiple uiaxes in uigridlayout (plots + UI controls)

```matlab
fig = uifigure;
gl = uigridlayout(fig, [2 2]);
gl.RowHeight = {'1x', '1x'};
gl.ColumnWidth = {'1x', '1x'};

ax1 = uiaxes(gl); ax1.Layout.Row = 1; ax1.Layout.Column = 1;
ax2 = uiaxes(gl); ax2.Layout.Row = 1; ax2.Layout.Column = 2;
ax3 = uiaxes(gl); ax3.Layout.Row = 2; ax3.Layout.Column = [1 2];
```

## When to Use Which

- **`tiledlayout`**: pure plot grids — shared titles/labels, compact spacing, linked axes
- **`uigridlayout`**: plots alongside UI controls, or non-uniform layout mixing components and axes

----

Copyright 2026 The MathWorks, Inc.

----
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall