Bubbleplot - Multidimensional scatter plots

Visualize up to 6 dimensions of data using point clouds
Updated 1 Sep 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Bubbleplot produces a scatter plot that enables the visualization of up to 6-dimensional data. The dimensions used for displaying data include the X, Y and Z coordinates, the marker sizes, colors and shapes. The data types can be numerical or categorical (or strings). You can also label each point with a text annotation
This function works really well with clickableLegend, allowing you to highlight or hide/show groups of points in the bubble plot.
bubbleplot(x, y, z, siz, col, shape)
draws a 3D bubble plot. See input parameter description below.

bubbleplot(x, y, [], siz, col, shape)
draws a 2D bubble plot.

bubbleplot(..., textarray)
enables you to pass in a cell array of strings to annotate each point
on the plot. By default the strings are displayed as text labels as well
as stored in the UserData property of the line objects

bubbleplot(..., textarray, 'ShowText', false)
will not display the text on screen, but will store it in the user
data property. This can be useful when creating a custom data tip.

[hLine, hText] = bubbleplot(...)
returns a vector of line handles to the points in the plot and
(if appropriate) a vector of handles to the text objects on the

The inputs should be vectors of the same length, with the following
Input Required Default-Value Type
x, y, z Yes N/A Numerical (Continuous or discrete)
siz No 8 Numerical (Continuous or discrete)
col No col = z Numerical or Categorical*
shape No 'o' Categorical* (upto 13 unique discrete values)

* "Categorical" variables can either be numeric with discrete values or
non-numeric data types that support a "UNIQUE" method. Examples of this
can be a cell array of strings, a nominal array or ordinal array.

* The siz variable is normalized to a marker size range of 3 to 20. To
specify a custom size range use the optional parameter
'markerSizeLimits'. Example: bubbleplot(..., 'MarkerSizeLimits', [5 32])

* The shape variable can also be a character that represents a marker
shape to be used for all points

* If col is a categorical variable, ensure it is integer-valued so that
it is handled correctly. If it is not integer valued, bubbleplot will
check to see if the number of unique values is less than 10% of the
length of the vector and use that to determine if the variable is
categorical. The colors used to depict categorical data are evenly
spaced (1 color level per unique category/label). However if col is
not categorical, its values are simply scaled to different values in
the colormap

* The default font size used to display the text labels is 8 pt with a
left alignment. Use the input arguments 'FontSize' and 'Alignment' to
control these properties.
Example: bubbleplot(..., 'FontSize', 6, 'Alignment', 'center')

* You can specify a custom colormap using the Colormap argument. The
parameter can be a string (eg. 'cool'), a function handle (eg. @jet) or
an N-by-3 matrix of color RGB levels.
Example: bubbleplot(..., 'ColorMap', cmap)

Cite As

Ameya Deoras (2024). Bubbleplot - Multidimensional scatter plots (https://www.mathworks.com/matlabcentral/fileexchange/48005-bubbleplot-multidimensional-scatter-plots), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Updated license