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/interactive-plots.md

View on GitHub
# Interactive Plots

## Click on Plot Objects

`ButtonDownFcn` works on plot objects (lines, scatter, bars) but NOT reliably on uiaxes itself:

```matlab
p = plot(ax, x, y);
p.ButtonDownFcn = @(src, event) onLineClicked(src, event);

function onLineClicked(~, event)
    pt = event.IntersectionPoint;  % [x, y, z] in data coordinates
    fprintf('Clicked at x=%.2f, y=%.2f\n', pt(1), pt(2));
end
```

## Mouse Callbacks on Figure

```matlab
fig.WindowButtonDownFcn   = @(src, evt) onMouseDown(src, evt, ax);
fig.WindowButtonMotionFcn = @(src, evt) onMouseMove(src, evt, ax);
fig.WindowButtonUpFcn     = @(src, evt) onMouseUp(src, evt);
fig.WindowScrollWheelFcn  = @(src, evt) onScroll(src, evt, ax);
fig.WindowKeyPressFcn     = @(src, evt) onKeyPress(src, evt);
```

**Cursor position in data coordinates:**
```matlab
function onMouseMove(~, ~, ax)
    pt = ax.CurrentPoint;     % 2x3 matrix
    xData = pt(1,1);
    yData = pt(1,2);
end
```

**Key event data:** `evt.Key` (name), `evt.Character` (char), `evt.Modifier` (cell array)

**Scroll event data:** `evt.VerticalScrollCount` — positive = scroll down

## Drag Interaction Pattern

```matlab
function setupDrag(fig, ax, marker)
    fig.WindowButtonDownFcn = @startDrag;

    function startDrag(~, ~)
        fig.WindowButtonMotionFcn = @doDrag;
        fig.WindowButtonUpFcn = @endDrag;
    end

    function doDrag(~, ~)
        pt = ax.CurrentPoint;
        marker.XData = pt(1,1);
        marker.YData = pt(1,2);
    end

    function endDrag(~, ~)
        fig.WindowButtonMotionFcn = '';
        fig.WindowButtonUpFcn = '';
    end
end
```

## HitTest and PickableParts

```matlab
p.HitTest = 'off';         % clicks pass through to object below
p.PickableParts = 'none';  % never picks up clicks
```

## Controlling Built-In Interactions

```matlab
% Default set
ax.Interactions = [zoomInteraction rulerPanInteraction dataTipInteraction];

% 3D rotation
ax.Interactions = [rotateInteraction dataTipInteraction];

% Zoom only
ax.Interactions = zoomInteraction;

% Disable all
disableDefaultInteractivity(ax);
```

**Fine-grained options:**
```matlab
ax.InteractionOptions.PanSupported = "off";
ax.InteractionOptions.LimitsDimensions = "x";       % zoom x-axis only
```

**Toolbar:**
```matlab
ax.Toolbar.Visible = 'off';   % hide toolbar
ax.Toolbar = [];               % remove entirely (performance boost)
```

## Enable, Disable, and Customize Built-In Interactions

- The following callbacks can cause MATLAB to disable built-in axes interactions:

  - `WindowButtonDownFcn`
  - `WindowButtonMotionFcn`
  - `WindowButtonUpFcn`
  - `WindowScrollWheelFcn`
  - `ButtonDownFcn`

- Use `ax.InteractionOptions` to customize supported interaction behavior, such as disabling pan or limiting zoom to specific dimensions.
- Use `disableDefaultInteractivity(ax)` / `enableDefaultInteractivity(ax)` to disable or enable the built-in interaction set as a whole.

----

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: 197kUpdated 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: 197kUpdated 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: 197kUpdated Claude CodeCodexVerifiedInstall