scatterhist — Create a scatter plot with marginal histograms.
scatterhist(x,y) creates a scatter plot with marginal distributions for vector inputs x and y. scatterhist(x,y,Name,Value) supports common MATLAB-compatible controls including NBins, Group, PlotGroup, Kernel, Style, Bandwidth, Legend, Location, Direction, Color, Marker, MarkerSize, LineStyle, LineWidth, and Parent. The return value is a three-element axes-handle vector for the scatter axes, x marginal axes, and y marginal axes.
Syntax
scatterhist(x, y)
scatterhist(x, y, Name, Value)
h = scatterhist(___)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
x | NumericArray | Yes | — | X observations. |
y | NumericArray | Yes | — | Y observations. |
nameValuePairs | Any | Variadic | — | Scatterhist name-value options. |
Returns
| Name | Type | Description |
|---|---|---|
h | NumericArray | Three axes handles: scatter, x marginal, and y marginal. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:scatterhist:InvalidArgument | Observation vectors or name-value options are malformed. | scatterhist: invalid argument |
RunMat:scatterhist:Internal | RunMat cannot allocate or render the scatterhist chart. | scatterhist: internal error |
Examples
Create a scatter plot with marginal histograms
h = scatterhist([0; 0.2; 0.8; 1], [0; 0.1; 0.9; 1], 'NBins', [2 2])Expected output:
h is a 3-by-1 vector of axes handles.Group observations and show kernel marginals
g = ["a"; "b"; "a"; "b"];
h = scatterhist(x, y, 'Group', g, 'Kernel', 'overlay', 'Legend', 'on');Expected output:
RunMat renders grouped scatter series with marginal density lines.Using scatterhist with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how scatterhist changes the result.
Run a small scatterhist example, explain the result, then change one input and compare the output.
Related functions
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.