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

NameTypeRequiredDefaultDescription
xNumericArrayYesX observations.
yNumericArrayYesY observations.
nameValuePairsAnyVariadicScatterhist name-value options.

Returns

NameTypeDescription
hNumericArrayThree axes handles: scatter, x marginal, and y marginal.

Errors

IdentifierWhenMessage
RunMat:scatterhist:InvalidArgumentObservation vectors or name-value options are malformed.scatterhist: invalid argument
RunMat:scatterhist:InternalRunMat 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.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.