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/animation.md

View on GitHub
# Animation and Streaming Data

## Update in Place (Primary Pattern)

Create the plot object once, then update its data properties:

```matlab
p = plot(ax, x, y, 'LineWidth', 1.5);
xlim(ax, [0 10]);
ylim(ax, [-1 1]);

for k = 1:N
    p.YData = newData(k, :);
    drawnow limitrate
end
```

MUST set axis limits before the loop to skip auto-limit recalculation.

## animatedline (Growing/Streaming Data)

```matlab
a = animatedline(ax, 'Color', [0 0.45 0.74], 'LineWidth', 1.5);
a.MaximumNumPoints = 500;  % rolling window — auto-drops old points

xlim(ax, [0 20]);
ylim(ax, [-1 1]);

for k = 1:N
    addpoints(a, t(k), signal(k));
    drawnow limitrate
end
```

**Key methods:** `addpoints(a, x, y)`, `clearpoints(a)`, `getpoints(a)`

## Preallocate with NaN

```matlab
p = plot(ax, NaN(1, 1000), NaN(1, 1000));
for i = 1:1000
    p.XData(i) = t(i);
    p.YData(i) = signal(i);
    if mod(i, 10) == 0  % update display every 10 points
        drawnow limitrate
    end
end
```

## Batch Multi-Property Update

```matlab
set(p, 'XData', newX, 'YData', newY, 'Color', [1 0 0]);
```

## Timer-Based Streaming

```matlab
tmr = timer('ExecutionMode', 'fixedRate', 'Period', 0.05, ...
    'TimerFcn', @(~,~) updateSignal(), 'BusyMode', 'drop');
start(tmr);

fig.CloseRequestFcn = @(~,~) cleanup();

function cleanup()
    stop(tmr);
    delete(tmr);
    delete(fig);
end
```

Use `'BusyMode', 'drop'` to skip missed frames rather than queuing them.

## Performance Summary

| Technique | Benefit |
|---|---|
| `p.XData = newX` not `plot()` | Avoids object recreation |
| `animatedline` + `addpoints` | Optimal for streaming data |
| `drawnow limitrate` | Caps at ~20 fps, prevents backlog |
| Set `xlim`/`ylim` before loop | Skips auto-limit recalculation |
| `ax.Toolbar = []` | Removes toolbar overhead |
| `disableDefaultInteractivity(ax)` | Removes interaction overhead |
| Batch `addpoints` calls | Reduces render frequency |
| Combine scatter objects | 1 scatter with N points vs N scatter with 1 point |
| `set()` for multi-property | Single render pass |

----

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