bubblechart

Draws a scatter plot whose markers vary in size and color.

Category: Graphics > 2-D and 3-D Plots

Syntax

bubblechart(x, y, sz)

Draws a bubble at each (x, y) with area scaled by sz.

bubblechart(x, y, sz, c)

Also colors the bubbles by c.

b = bubblechart(___)

Also returns the BubbleChart object.

Description

A bubble chart adds a third (and optionally fourth) variable to a scatter plot. The sizes in sz are data values, not points: bubblesize sets the smallest and largest bubble on screen, bubblelim the data range they span, and bubblelegend explains the mapping.

Input arguments

x, y
Vectors of coordinates.
sz
Vector of the same length giving the size of each bubble; it is scaled to the range set by bubblesize.
c
Colors: one value per bubble (mapped through the colormap) or a color specification.

Output arguments

b
The BubbleChart object.

Example

Population versus income

x = [1 2 3 4 5];
y = [3 1 4 2 5];
sz = [10 40 25 80 55];
bubblechart(x, y, sz, [1 2 3 4 5]);
bubblelegend('Size')
colorbar

In the app, the figure is drawn below the code.

See also

bubblechart3 bubblesize bubblelim bubblelegend scatter