BubbleChart - Bubble chart appearance and behavior - MATLAB (original) (raw)

BubbleChart Properties

Bubble chart appearance and behavior

Since R2020b

BubbleChart properties control the appearance and behavior of aBubbleChart object. By changing property values, you can modify certain aspects of the chart. Use dot notation to query and set properties.

b = bubblechart(rand(1,10),rand(1,10),1:10); b.MarkerFaceColor = 'r';

Markers

expand all

Marker fill color, specified as 'flat', 'auto', an RGB triplet, a hexadecimal color code, a color name, or a short name. The 'flat' option uses the CData values. The 'auto' option uses the same color as the Color property for the axes.

For a custom color, specify an RGB triplet or a hexadecimal color code.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and the hexadecimal color codes.

Color Name Short Name RGB Triplet Hexadecimal Color Code Appearance
"red" "r" [1 0 0] "#FF0000" Sample of the color red
"green" "g" [0 1 0] "#00FF00" Sample of the color green
"blue" "b" [0 0 1] "#0000FF" Sample of the color blue
"cyan" "c" [0 1 1] "#00FFFF" Sample of the color cyan
"magenta" "m" [1 0 1] "#FF00FF" Sample of the color magenta
"yellow" "y" [1 1 0] "#FFFF00" Sample of the color yellow
"black" "k" [0 0 0] "#000000" Sample of the color black
"white" "w" [1 1 1] "#FFFFFF" Sample of the color white
"none" Not applicable Not applicable Not applicable No color

This table lists the default color palettes for plots in the light and dark themes.

Palette Palette Colors
"gem" — Light theme default_Before R2025a: Most plots use these colors by default._ Sample of the "gem" color palette
"glow" — Dark theme default Sample of the "glow" color palette

You can get the RGB triplets and hexadecimal color codes for these palettes using the orderedcolors and rgb2hex functions. For example, get the RGB triplets for the "gem" palette and convert them to hexadecimal color codes.

RGB = orderedcolors("gem"); H = rgb2hex(RGB);

Before R2023b: Get the RGB triplets using RGB = get(groot,"FactoryAxesColorOrder").

Before R2024a: Get the hexadecimal color codes using H = compose("#%02X%02X%02X",round(RGB*255)).

Example: [0.3 0.2 0.1]

Example: 'green'

Example: '#D2F9A7'

Marker edge transparency, specified as a scalar in the range [0,1] or 'flat'. A value of 1 is opaque and 0 is completely transparent. Values between 0 and 1 are semitransparent.

To set the edge transparency to a different value for each point in the plot, set theAlphaData property to a vector the same size as theXData property, and set theMarkerEdgeAlpha property to 'flat'.

Marker face transparency, specified as a scalar in the range [0,1] or 'flat'. A value of 1 is opaque and 0 is completely transparent. Values between 0 and 1 are partially transparent.

To set the marker face transparency to a different value for each point, set the AlphaData property to a vector the same size as the XData property, and set the MarkerFaceAlpha property to 'flat'.

Transparency data for each plotted point, specified as an array the same size as theXData property. After specifying the values, set theMarkerFaceAlpha and MarkerEdgeAlpha properties to control the type of transparency. If theMarkerFaceAlpha and MarkerEdgeAlpha properties are both set to scalar values, then the BubbleChart object does not use the AlphaData values.

The AlphaDataMapping property determines how theBubbleChart object interprets the AlphaData property values.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Control how the AlphaData property is set, specified as one of these values:

Color and Size Data

expand all

Marker colors, specified as one of these values:

Example: [1 0 0; 0 1 0; 0 0 1]

Control how the CData property is set, specified as one of these values:

Variable linked to CData, specified as a character vector or string containing a MATLAB workspace variable. MATLAB evaluates the variable in the base workspace to generate theCData.

By default, there is no linked variable so the value is an empty character vector. If you link a variable, then MATLAB does not update the CData values immediately. To force an update of the data values, use the refreshdata function.

Note

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.

Series index, specified as a positive whole number or "none". This property is useful for reassigning the marker colors of BubbleChart objects so that they match the colors of other objects. By default, theSeriesIndex property is a number that corresponds to the object's order of creation, starting at 1.

MATLAB uses the number to calculate indices for assigning colors when you call plotting functions. The indices refer to the rows of the arrays stored in theColorOrder property of the axes. The marker colors change when you change the BubbleChart object's SeriesIndex value, or when you change ColorOrder property of the axes.

A SeriesIndex value of"none" corresponds to a neutral color that does not participate in the indexing scheme. (since R2023b)

How Manual Color Assignment Overrides SeriesIndex Behavior

To manually control the fill color of the markers, use either of these approaches:

Manually controlling the edge colors of the markers works the same way, except that you set MarkerEdgeColor property to a color value or"flat".

When you manually set the color of an object, MATLAB disables automatic color selection for that object and allows your color to persist, regardless of the value of the SeriesIndex property. The CDataMode property indicates whether theCData colors have been set manually (by you) or automatically. A value of "manual" indicates manual selection, and a value of "auto" indicates automatic selection.

Automatic color selection is disabled when you perform either of these actions:

To enable automatic selection again, set the MarkerFaceColor,MarkerEdgeColor, or both properties to"flat". Set the CDataMode property to"auto", and set the SeriesIndex property to a positive whole number.

In some cases, MATLAB sets the SeriesIndex value to0, which also disables automatic color selection.

Relative bubble sizes, specified in one of these forms:

The SizeData values control the relative distribution of the bubble sizes. By default, MATLAB linearly maps a range of bubble areas across the range of theSizeData values for all the bubble charts in the axes. For more control over the absolute bubble sizes, and how they map across the range of theSizeData values, see bubblesize and bubblelim.

Control how the SizeData property is set, specified as one of these values:

Variable linked to SizeData, specified as a character vector or string containing a MATLAB workspace variable. MATLAB evaluates the variable in the base workspace to generate theSizeData.

By default, there is no linked variable so the value is an empty character vector. If you link a variable, then MATLAB does not update the SizeData values. To force an update of the data values, use the refreshdata function.

Note

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.

Cartesian Coordinate Data

expand all

x values, specified as a scalar or a vector. The chart displays bubble for each value in XData.

The input argument X to the bubblechart and bubblechart3 functions set the x values.XData and YData must have equal lengths.

Example: [1 2 4 2 6]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | categorical | datetime | duration

Control how the XData property is set, specified as one of these values:

y values, specified as a scalar or a vector. The chart displays bubble for each value in YData.

The input argument Y to the bubblechart and bubblechart3 functions set the y values.XData and YData must have equal lengths.

Example: [1 3 3 4 6]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | categorical | datetime | duration

Control how the YData property is set, specified as one of these values:

z values, specified as a scalar or a vector.

Example: [1 2 2 1 0]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | categorical | datetime | duration

Control how the ZData property is set, specified as one of these values:

Type of jitter (spacing of points) along the _x_-dimension, specified as one of the following values:

Maximum amount of jitter (offset between points) along the _x_-dimension, specified as a nonnegative scalar value in data units.

For example, to set the jitter width to 90% of the shortest distance between adjacent points, take the minimum distance between unique values of x and scale by0.9.

XJitterWidth = 0.9 * min(diff(unique(x)));

Since R2025a

Direction of jitter along the _x_-dimension, specified as one of these values:

Type of jitter (spacing of points) along the _y_-dimension, specified as one of the following values:

Maximum amount of jitter (offset between points) along the_y_-dimension, specified as a nonnegative scalar value in data units.

For example, to set the jitter width to 90% of the shortest distance between adjacent points, take the minimum distance between unique values of y and scale by0.9.

YJitterWidth = 0.9 * min(diff(unique(y)));

Since R2025a

Direction of jitter along the _y_-dimension, specified as one of these values:

Type of jitter (spacing of points) along the _z_-dimension, specified as one of the following values:

Maximum amount of jitter (offset between points) along the _z_-dimension in data units, specified as a nonnegative scalar value.

For example, to set the jitter width to 90% of the shortest distance between adjacent points, take the minimum distance between unique values ofz and scale by0.9.

ZJitterWidth = 0.9 * min(diff(unique(z)));

Since R2025a

Direction of jitter along the _z_-dimension, specified as one of these values:

Polar Coordinate Data

expand all

Radius values, specified as a vector. ThetaData andRData must be vectors of equal length.

This property applies only to polar axes.

Control how the RData property is set, specified as one of these values:

Variable linked to RData, specified as a character vector or string containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate theRData.

By default, there is no linked variable so the value is an empty character vector,''. If you link a variable, then MATLAB does not update the RData values immediately. To force an update of the data values, use the refreshdata function.

Note

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.

This property applies only to polar axes.

Angle values, specified as a vector. ThetaData andRData must be vectors of equal length.

This property applies only to polar axes.

Control how the ThetaData property is set, specified as one of these values:

Variable linked to ThetaData, specified as a character vector or string containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate theRData.

By default, there is no linked variable so the value is an empty character vector,''. If you link a variable, then MATLAB does not update the ThetaData values immediately. To force an update of the data values, use the refreshdata function.

Note

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.

This property applies only to polar axes.

Geographic Coordinate Data

expand all

Latitude values, specified as a vector. LatitudeData andLongitudeData must be vectors of equal length.

This property applies only to geographic axes.

Control how the LatitudeData property is set, specified as one of these values:

This property applies only to geographic axes.

Variable linked to LatitudeData, specified as a character vector or string containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate theRData.

By default, there is no linked variable so the value is an empty character vector,''. If you link a variable, MATLAB does not update the LatitudeData values immediately. To force an update of the data values, use the refreshdata function.

Note

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.

This property applies only to geographic axes.

Longitude values, specified as a vector. LongitudeData andLatitudeData must be vectors of equal length.

This property applies only to geographic axes.

Control how the LongitudeData property is set, specified as one of these values:

This property applies only to geographic axes.

Variable linked to LongitudeData, specified as a character vector or string containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate theRData.

By default, there is no linked variable so the value is an empty character vector,''. If you link a variable, MATLAB does not update the LatitudeData values immediately. To force an update of the data values, use the refreshdata function.

Note

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.

This property applies only to geographic axes.

Table Data

expand all

Source table containing the data to plot, specified as a table or timetable.

Table variable containing the _x_-coordinates, specified using one of the indexing schemes from the following table. The variable you specify can contain numeric, categorical, datetime, or duration values. When you set this property, MATLAB updates the XData property.

This table lists the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing the _y_-coordinates, specified using one of the indexing schemes from the following table. The variable you specify can contain numeric, categorical, datetime, or duration values. When you set this property, MATLAB updates the YData property.

This table lists the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing the _z_-coordinates, specified using one of the indexing schemes from the following table. The variable you specify can contain numeric, categorical, datetime, or duration values. When you set this property, MATLAB updates the ZData property.

This table lists the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing the radius values, specified using one of the indexing schemes from the following table. The variable you specify can contain any type of numeric values. When you set this property, MATLAB updates the RData property.

Here is a list of the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing the angle values, specified using one of the indexing schemes from the following table. The variable you specify can contain any type of numeric values. When you set this property, MATLAB updates the ThetaData property.

Here is a list of the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing the latitude values for geographic plots, specified using one of the indexing schemes from the following table. When you set this property, MATLAB updates the LatitudeData property.

Here is a list of the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing the longitude values for geographic plots, specified using one of the indexing schemes from the following table. When you set this property, MATLAB updates the LongitudeData property.

Here is a list of the different indexing schemes you can use to specify the table variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Table variable containing marker size data, specified as a variable index into the source table.

Specifying the Table Index

Use any of the following indexing schemes to specify the desired variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Specifying Size Data

The variable you specify can contain any numeric type. When you set theSizeVariable property, MATLAB updates the SizeData property.

Table variable containing the color data, specified as a variable index into the source table.

Specifying the Table Index

Use any of the following indexing schemes to specify the desired variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Specifying Color Data

Specifying the ColorVariable property controls the colors of the markers. The data in the variable controls the marker fill color when theMarkerFaceColor property is set to"flat". The data can also control the marker outline color, when the MarkerEdgeColor is set to"flat".

The table variable you specify can contain values of any numeric type. The values can be in either of the following forms:

When you set the ColorVariable property, MATLAB updates the CData property.

Table variable containing transparency data, specified as a variable index into the source table.

Specifying the Table Index

Use any of the following indexing schemes to specify the desired variable.

Indexing Scheme Examples
Variable name:A string scalar or character vector.A pattern object. The pattern object must refer to only one variable. "A" or 'A' — A variable named A"Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit
Variable index:An index number that refers to the location of a variable in the table.A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values. 3 — The third variable from the table[false false true] — The third variable
Variable type:A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable. vartype("double") — The variable containing double values

Specifying Transparency Data

The data in the variable you specify controls the transparency of the markers. Smaller values are more transparent, and larger values are more opaque. The values can be any numeric type.

After setting the AlphaVariable property, set the MarkerFaceAlpha and MarkerEdgeAlpha properties to control the type of transparency. If the MarkerFaceAlpha and MarkerEdgeAlpha properties are both set to scalar values, then the scatter object does not use the data from the table.

When you set this property, MATLAB updates the AlphaData property.

Legend

expand all

Legend label, specified as a character vector or string scalar. The legend does not display until you call the legend command. If you do not specify the text, then legend sets the label using the form'dataN'.

Interactivity

expand all

Data tip content, specified as a DataTipTemplate object. You can control the content that appears in a data tip by modifying the properties of the underlying DataTipTemplate object. For a list of properties, seeDataTipTemplate Properties.

For an example of modifying data tips, see Create Custom Data Tips.

Note

The DataTipTemplate object is not returned byfindobj or findall, and it is not copied by copyobj.

Callbacks

Callback Execution Control

expand all

This property is read-only.

Parent/Child

expand all

Parent, specified as an Axes, PolarAxes,GeographicAxes object, Group, orTransform object.

Identifiers

expand all

This property is read-only.

Type of graphics object, returned as 'bubblechart'. Use this property to find all objects of a given type within a plotting hierarchy, for example, searching for the type using findobj.

Object identifier, specified as a character vector or string scalar. You can specify a unique Tag value to serve as an identifier for an object. When you need access to the object elsewhere in your code, you can use the findobj function to search for the object based on the Tag value.

Version History

Introduced in R2020b

expand all

Set the XJitterDirection, YJitterDirection, and ZJitterDirection properties to control the direction of the jitter in your chart. Each of these properties can have a value of "negative","positive", or "both".

Opt out of automatic color selection for BubbleChart objects by setting theSeriesIndex property to "none". When you specify"none", the BubbleChart object has a neutral color.

To enable automatic color selection again, set the SeriesIndex property to a positive whole number.