# bubblechart3

3-D bubble chart

## Syntax

``bubblechart3(x,y,z,sz)``
``bubblechart3(x,y,z,sz,c)``
``bubblechart3(tbl,xvar,yvar,zvar,sizevar)``
``bubblechart3(tbl,xvar,yvar,zvar,sizevar,cvar)``
``bubblechart3(ax,___)``
``bubblechart3(___,Name,Value)``
``bc = bubblechart3(___)``

## Description

### Vector and Matrix Data

example

````bubblechart3(x,y,z,sz)` displays colored circular markers (bubbles) at the locations specified by the vectors `x`, `y`, and `z`. Specify bubbles sizes as the vector `sz`. The vectors `x`, `y`, `z` and `sz` must be the same length.```

example

````bubblechart3(x,y,z,sz,c)` specifies the colors of the bubbles. To use one color for all the bubbles, specify a color name, a hexadecimal color code, or an RGB triplet.To assign a different color to each bubble, specify a vector the same length as `x`, `y`, and `z`. Alternatively, you can specify a three-column matrix of RGB triplets. the number of rows in the matrix must match the length of `x`, `y`, and `z`. ```

### Table Data

example

````bubblechart3(tbl,xvar,yvar,zvar,sizevar)` plots the variables `xvar`, `yvar`, and `zvar` from the table `tbl` and uses the variable `sizevar` for the bubble sizes. To plot one data set, specify one variable each for `xvar`, `yvar`, `zvar`, and `sizevar`. To plot multiple data sets, specify multiple variables for at least one of those arguments. The arguments that specify multiple variables must specify the same number of variables.```

example

````bubblechart3(tbl,xvar,yvar,zvar,sizevar,cvar)` plots the specified variables from the table using the colors specified in the variable `cvar`. To specify colors for multiple data sets, specify `cvar` as multiple variables. The number of variables must match the number of data sets.```

example

````bubblechart3(ax,___)` displays the bubble chart in the target axes `ax`. Specify the axes before all other input arguments.```

example

````bubblechart3(___,Name,Value)` specifies `BubbleChart` properties using one or more name-value arguments. Specify the properties after all other input arguments. For example, `bubblechart3(x,y,z,'LineWidth',2)` creates a bubble chart with 2-point marker outlines. For a list of properties, see BubbleChart Properties.```

example

````bc = bubblechart3(___)` returns the `BubbleChart` object. Use `bc` to modify properties of the chart after creating it. For a list of properties, see BubbleChart Properties.```

## Examples

collapse all

Define a set of bubble coordinates as the vectors `x`, `y`, and `z`. Define `sz` as a vector that specifies the bubble sizes. Then create a bubble chart of `x`, `y`, and `z`.

```x = rand(1,20); y = rand(1,20); z = rand(1,20); sz = rand(1,20); bubblechart3(x,y,z,sz);``` Define a set of bubble coordinates as the vectors `x`, `y`, and `z`. Define `sz` as a vector that specifies the bubble sizes. Then create a bubble chart of `x`, `y`, and `z`, and specify the color as red. By default, the bubbles are partially transparent.

```x = rand(1,20); y = rand(1,20); z = rand(1,20); sz = rand(1,20); bubblechart3(x,y,z,sz,'red');``` For a custom color, you can specify an RGB triplet or a hexadecimal color code. For example, the hexadecimal color code `'#7031BB'`, specifies a shade of purple.

`bubblechart3(x,y,z,sz,'#7031BB');` You can also specify a different color for each bubble. For example, specify a vector to select colors from the figure's colormap.

```c = 1:20; bubblechart3(x,y,z,sz,c)``` Define a set of bubble coordinates as the vectors `x`, `y`, and `z`. Define `sz` as a vector that specifies the bubble sizes. Then create a bubble chart of `x`, `y`, and `z`. By default, the bubbles are 60% opaque, and the edges are completely opaque with the same color.

```x = rand(1,20); y = rand(1,20); z = rand(1,20); sz = rand(1,20); bubblechart3(x,y,z,sz);``` You can customize the opacity and the outline color by setting the `MarkerFaceAlpha` and `MarkerEdgeColor` properties, respectively. One way to set a property is by specifying a name-value pair argument when you create the chart. For example, you can specify 20% opacity by setting the `MarkerFaceAlpha` value to `0.20`.

`bc = bubblechart3(x,y,z,sz,'MarkerFaceAlpha',0.20);` If you create the chart by calling the `bubblechart3` function with a return argument, you can use the return argument to set properties on the chart after creating it. For example, you can change the outline color to purple.

`bc.MarkerEdgeColor = [0.5 0 0.5];` Define a data set that shows the contamination levels of a certain toxin across different towns in a metropolitan area.

• Define `towns` as the populations of the towns.

• Define `nsites` as the number of industrial sites in the corresponding towns.

• Define `nregulated` as the number of industrial sites that conform to the local environmental regulations.

• Define `levels` as the contamination levels in the towns.

```towns = randi([25000 500000],[1 30]); nsites = randi(10,1,30); nregulated = (-3 * nsites) + (5 * randn(1,30) + 20); levels = (3 * nsites) + (7 * randn(1,30) + 20);```

Display the data in a bubble chart. Create axis labels using the `xlabel`, `ylabel`, and `zlabel` functions. Use the `bubblesize` function to make all the bubbles between 5 and 30 points in diameter. Then add a bubble legend that shows the relationship between bubble size and population.

```bubblechart3(nsites,nregulated,levels,towns) xlabel('Industrial Sites') ylabel('Regulated Sites') zlabel('Contamination Level') bubblesize([5 30]) bubblelegend('Town Population','Location','eastoutside')``` A convenient way to plot data from a table is to pass the table to the `bubblechart3` function and specify the variables you want to plot. For example, create a table with five variables of random numbers. Plot the `X1`, `Y`, `Z` and `Sz` variables by passing the table as the first argument to the `bubblechart3` function followed by the variable names. By default, the axis labels match the variable names.

```tbl = table(randn(15,1)-10,randn(15,1)+10,rand(15,1), ... rand(15,1),rand(15,1), ... 'VariableNames',{'X1','X2','Y','Z','Sz'}); bubblechart3(tbl,'X1','Y','Z','Sz')``` You can also plot multiple variables at the same time. For example, plot `X1` and `X2` on the x-axis by specifying the `xvar` argument as the cell array `{'X1','X2'}`. Then add a legend. The legend labels match the variable names.

```bubblechart3(tbl,{'X1','X2'},'Y','Z','Sz') legend``` You can plot data from a table and customize the colors by specifying the `cvar` argument when you call `bubblechart3`.

For example, create a table with five variables of random numbers, and plot the `X`, `Y`, and `Z` variables. Vary the bubble sizes according to the `Sz` variable, and vary the colors according to the `Colors` variable.

```tbl = table(randn(15,1)-10,randn(15,1)+10,rand(15,1), ... rand(15,1),rand(15,1), ... 'VariableNames',{'X','Y','Z','Sz','Colors'}); bubblechart3(tbl,'X','Y','Z','Sz','Colors');``` Define two sets of data that show the contamination levels of a certain toxin across different towns on the east and west sides of a certain metropolitan area.

• Define `towns1` `and` `towns2` as the populations of the towns.

• Define `nsites1` and `nsites2` as the number of industrial sites in the corresponding towns.

• Define `nregulated1` and `nregulated2` as the number of industrial sites that conform to the local environmental regulations.

• Define `levels1` and `levels2` as the contamination levels in the towns.

```towns1 = randi([25000 500000],[1 30]); towns2 = towns1/3; nsites1 = randi(10,1,30); nsites2 = randi(10,1,30); nregulated1 = (-3 * nsites1) + (5 * randn(1,30) + 20); nregulated2 = (-2 * nsites2) + (5 * randn(1,30) + 20); levels1 = (3 * nsites1) + (7 * randn(1,30) + 20); levels2 = (5 * nsites2) + (7 * randn(1,30) + 20);```

Create a tiled chart layout so you can visualize the data side-by-side. Then create an axes object in the first tile and plot the data for the east side of the city. Add a title and axis labels. Then repeat the process in the second tile to plot the west side data.

```tiledlayout(2,1,'TileSpacing','compact') ax1 = nexttile; % East side bubblechart3(ax1,nsites1,nregulated1,levels1,towns1); title('East Side') xlabel('Industrial Sites') ylabel('Regulated Sites') zlabel('Contamination Level') % West side ax2 = nexttile; bubblechart3(ax2,nsites2,nregulated2,levels2,towns2); title('West Side') xlabel('Industrial Sites') ylabel('Regulated Sites') zlabel('Contamination Level')``` Reduce all the bubble sizes to make it easier to see all the bubbles. In this case, change the range of diameters to be between `5` and `20` points.

```bubblesize(ax1,[5 20]) bubblesize(ax2,[5 20])``` The east side towns are three times the size of the west side towns, but the bubble sizes do not reflect this information in the preceding charts. This is because the smallest and largest bubbles map to the smallest and largest data points in each of the axes. To display the bubbles on the same scale, define a vector called `alltowns` that includes the populations from both sides of the city. The use the `bubblelim` function to reset the scaling for both charts.

```alltowns = [towns1 towns2]; newlims = [min(alltowns) max(alltowns)]; bubblelim(ax1,newlims) bubblelim(ax2,newlims)``` ## Input Arguments

collapse all

x-coordinates, specified as a numeric scalar or vector the same length as `y` and `z`.

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

y-coordinates, specified as a numeric scalar or vector the same length as `x` and `z`.

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

z-coordinates, specified as a numeric scalar or vector the same length as `x` and `y`.

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

Bubble sizes, specified as a numeric scalar or vector the same length as `x`, `y`, and `z`.

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

Bubble color, specified as an RGB triplet, a color name, a hexadecimal color code, a matrix of RGB triplets, or a vector of colormap indices. You can display all the bubbles with the same color, or you can display each bubble with a different color. By default, the bubbles are filled with partially transparent color, and the edges of the bubbles are opaque.

#### Display the Bubbles with the Same Color

Specify one of the following values to display all the bubbles with the same color:

• RGB triplet — 1-by-3 row vector whose elements specify the intensities of the red, green, and blue components of a color. The intensities must be in the range `[0,1]`; for example, ```[0.4 0.6 0.7]```.

• Hexadecimal color code — Character vector or a string scalar that starts with a hash symbol (`#`) followed by three or six hexadecimal digits, which can range from `0` to `F`. The values are not case sensitive. Thus, the color codes `'#FF8800'`, `'#ff8800'`, `'#F80'`, and `'#f80'` are equivalent.

• Color name or short name — Color name or short name from the table below.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
`'red'``'r'``[1 0 0]``'#FF0000'` `'green'``'g'``[0 1 0]``'#00FF00'` `'blue'``'b'``[0 0 1]``'#0000FF'` `'cyan'` `'c'``[0 1 1]``'#00FFFF'` `'magenta'``'m'``[1 0 1]``'#FF00FF'` `'yellow'``'y'``[1 1 0]``'#FFFF00'` `'black'``'k'``[0 0 0]``'#000000'` `'white'``'w'``[1 1 1]``'#FFFFFF'` Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

`[0 0.4470 0.7410]``'#0072BD'` `[0.8500 0.3250 0.0980]``'#D95319'` `[0.9290 0.6940 0.1250]``'#EDB120'` `[0.4940 0.1840 0.5560]``'#7E2F8E'` `[0.4660 0.6740 0.1880]``'#77AC30'` `[0.3010 0.7450 0.9330]``'#4DBEEE'` `[0.6350 0.0780 0.1840]``'#A2142F'` #### Display the Bubbles with Different Colors

Specify one of the following values to assign a different color to each bubble:

• Three-column matrix of RGB triplets — Each row of the matrix specifies an RGB triplet color for the corresponding bubble. The values in each row specify the intensities of the red, green, and blue components of the color. The intensities must be in the range `[0,1]`. The number of rows must equal the length of the coordinate vectors.

• Vector of colormap indices — An m-by-1 vector of numbers that index into the current colormap. The values in the vector cover the full range of the colormap. The length of `c` must equal the length of the coordinate vectors. To change the colormap for the axes, use the `colormap` function.

Source table containing the data to plot. Specify this argument as a table or a timetable.

Table variables containing the x-coordinates, specified as one or more table variable indices.

#### Specifying Table Indices

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

Indexing SchemeExamples

Variable names:

• A character vector or a string scalar.

• A cell array or string vector.

• `'A'` or `"A"` — A variable called `A`

• `{'A','B'}` or `["A","B"]` — Two variables called `A` and `B`

Variable numbers:

• An index number that refers to the location of a variable in the table.

• A vector of numbers.

• `3` — The third variable from the table

• `[2 3]` — The second and third variables from the table

Logical vector:

• An `n`-element vector logical vector, where `logical 1` (`true`) values indicate the desired variables.

• Optionally, omit the trailing `false` values after the last `true` value.

• `[false false true false]` — The third variable from an `m`-by-`4` table

• `[false false true]` — The third variable from any size table

• `[false true true]` — The second and third variables from any size table

Variable type:

• `vartype('categorical')` — All the variables containing categorical values

The table variables you specify can contain numeric, categorical, datetime, or duration values.

To plot one data set, specify one variable each for `xvar`, `yvar`, `zvar`, `sizevar`, and optionally `cvar`. For example, read `Patients.xls` into the table `tbl`. Plot the `Height`, `Weight`, and `Diastolic` variables, and vary the bubble sizes according to the `Age` variable.

```tbl = readtable('Patients.xls'); bubblechart3(tbl,'Height','Weight','Diastolic','Age')```

To plot multiple data sets together, specify multiple variables for at least one of `xvar`, `yvar`, `zvar`, `sizevar`, or optionally `cvar`. If you specify multiple variables for more than one argument, the number of variables must be the same for each of those arguments.

For example, plot the `Weight` variable on the x-axis, the `Height` variable on the y-axis, and the `Systolic` and `Diastolic` variables on the z-axis. Specify the `Age` variable for the bubble sizes.

`bubblechart3(tbl,'Weight','Height',{'Systolic','Diastolic'},'Age')`

You can also use different indexing schemes for the table variables. For example, specify `xvar` and `xvar` as variable names, `zvar` as an index number, and `sizevar` as a logical vector.

`bubblechart3(tbl,'Height','Weight',9,[false false true])`

Table variables containing the y-coordinates, specified as one or more table variable indices.

#### Specifying Table Indices

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

Indexing SchemeExamples

Variable names:

• A character vector or a string scalar.

• A cell array or string vector.

• `'A'` or `"A"` — A variable called `A`

• `{'A','B'}` or `["A","B"]` — Two variables called `A` and `B`

Variable numbers:

• An index number that refers to the location of a variable in the table.

• A vector of numbers.

• `3` — The third variable from the table

• `[2 3]` — The second and third variables from the table

Logical vector:

• An `n`-element vector logical vector, where `logical 1` (`true`) values indicate the desired variables.

• Optionally, omit the trailing `false` values after the last `true` value.

• `[false false true false]` — The third variable from an `m`-by-`4` table

• `[false false true]` — The third variable from any size table

• `[false true true]` — The second and third variables from any size table

Variable type:

• `vartype('categorical')` — All the variables containing categorical values

The table variables you specify can contain numeric, categorical, datetime, or duration values.

To plot one data set, specify one variable each for `xvar`, `yvar`, `zvar`, `sizevar`, and optionally `cvar`. For example, read `Patients.xls` into the table `tbl`. Plot the `Height`, `Weight`, and `Diastolic` variables, and vary the bubble sizes according to the `Age` variable.

```tbl = readtable('Patients.xls'); bubblechart3(tbl,'Height','Weight','Diastolic','Age')```

To plot multiple data sets together, specify multiple variables for at least one of `xvar`, `yvar`, `zvar`, `sizevar`, or optionally `cvar`. If you specify multiple variables for more than one argument, the number of variables must be the same for each of those arguments.

For example, plot the `Weight` variable on the x-axis, the `Height` variable on the y-axis, and the `Systolic` and `Diastolic` variables on the z-axis. Specify the `Age` variable for the bubble sizes.

`bubblechart3(tbl,'Weight','Height',{'Systolic','Diastolic'},'Age')`

You can also use different indexing schemes for the table variables. For example, specify `xvar` and `xvar` as variable names, `zvar` as an index number, and `sizevar` as a logical vector.

`bubblechart3(tbl,'Height','Weight',9,[false false true])`

Table variables containing the z-coordinates, specified as one or more table variable indices.

#### Specifying Table Indices

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

Indexing SchemeExamples

Variable names:

• A character vector or a string scalar.

• A cell array or string vector.

• `'A'` or `"A"` — A variable called `A`

• `{'A','B'}` or `["A","B"]` — Two variables called `A` and `B`

Variable numbers:

• An index number that refers to the location of a variable in the table.

• A vector of numbers.

• `3` — The third variable from the table

• `[2 3]` — The second and third variables from the table

Logical vector:

• An `n`-element vector logical vector, where `logical 1` (`true`) values indicate the desired variables.

• Optionally, omit the trailing `false` values after the last `true` value.

• `[false false true false]` — The third variable from an `m`-by-`4` table

• `[false false true]` — The third variable from any size table

• `[false true true]` — The second and third variables from any size table

Variable type:

• `vartype('categorical')` — All the variables containing categorical values

The table variables you specify can contain numeric, categorical, datetime, or duration values.

To plot one data set, specify one variable each for `xvar`, `yvar`, `zvar`, `sizevar`, and optionally `cvar`. For example, read `Patients.xls` into the table `tbl`. Plot the `Height`, `Weight`, and `Diastolic` variables, and vary the bubble sizes according to the `Age` variable.

```tbl = readtable('Patients.xls'); bubblechart3(tbl,'Height','Weight','Diastolic','Age')```

To plot multiple data sets together, specify multiple variables for at least one of `xvar`, `yvar`, `zvar`, `sizevar`, or optionally `cvar`. If you specify multiple variables for more than one argument, the number of variables must be the same for each of those arguments.

For example, plot the `Weight` variable on the x-axis, the `Height` variable on the y-axis, and the `Systolic` and `Diastolic` variables on the z-axis. Specify the `Age` variable for the bubble sizes.

`bubblechart3(tbl,'Weight','Height',{'Systolic','Diastolic'},'Age')`

You can also use different indexing schemes for the table variables. For example, specify `xvar` and `xvar` as variable names, `zvar` as an index number, and `sizevar` as a logical vector.

`bubblechart3(tbl,'Height','Weight',9,[false false true])`

Table variables containing the bubble size data, specified as one or more table variable indices.

#### Specifying Table Indices

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

Indexing SchemeExamples

Variable names:

• A character vector or a string scalar.

• A cell array or string vector.

• `'A'` or `"A"` — A variable called `A`

• `{'A','B'}` or `["A","B"]` — Two variables called `A` and `B`

Variable numbers:

• An index number that refers to the location of a variable in the table.

• A vector of numbers.

• `3` — The third variable from the table

• `[2 3]` — The second and third variables from the table

Logical vector:

• An `n`-element vector logical vector, where `logical 1` (`true`) values indicate the desired variables.

• Optionally, omit the trailing `false` values after the last `true` value.

• `[false false true false]` — The third variable from an `m`-by-`4` table

• `[false false true]` — The third variable from any size table

• `[false true true]` — The second and third variables from any size table

Variable type:

• `vartype('categorical')` — All the variables containing categorical values

The table variables you specify can contain any type of numeric values.

If you are plotting one data set, specify one variable for `sizevar`. For example, read `Patients.xls` into the table `tbl`. Plot the `Height`, `Weight`, and `Diastolic` variables, and vary the bubble sizes according to the `Age` variable.

```tbl = readtable('Patients.xls'); bubblechart3(tbl,'Height','Weight','Diastolic','Age')```

If you are plotting multiple data sets, you can specify multiple variables for at least one of `xvar`, `yvar`, `zvar`, `sizevar`, or optionally `cvar`. If you specify multiple variables for more than one argument, the number of variables must be the same for each of those arguments.

For example, plot the `Weight` variable on the x-axis, the `Height` variable on the y-axis, and the `Age` variable on the z-axis. Specify the `Systolic` and `Diastolic` variables for the bubble sizes. The resulting plot shows two sets of bubbles with the same coordinates, but different bubble sizes.

`bubblechart3(tbl,'Weight','Height','Age',{'Systolic','Diastolic'})`

Table variables containing the bubble color data, specified as one or more table variable indices.

#### Specifying Table Indices

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

Indexing SchemeExamples

Variable names:

• A character vector or a string scalar.

• A cell array or string vector.

• `'A'` or `"A"` — A variable called `A`

• `{'A','B'}` or `["A","B"]` — Two variables called `A` and `B`

Variable numbers:

• An index number that refers to the location of a variable in the table.

• A vector of numbers.

• `3` — The third variable from the table

• `[2 3]` — The second and third variables from the table

Logical vector:

• An `n`-element vector logical vector, where `logical 1` (`true`) values indicate the desired variables.

• Optionally, omit the trailing `false` values after the last `true` value.

• `[false false true false]` — The third variable from an `m`-by-`4` table

• `[false false true]` — The third variable from any size table

• `[false true true]` — The second and third variables from any size table

Variable type:

• `vartype('categorical')` — All the variables containing categorical values

The table variables you specify can contain values of any numeric type. Each variable can be:

• A column of numbers that linearly map into the current colormap.

• A three-column array of RGB triplets. RGB triplets are three-element vectors whose values specify the intensities of the red, green, and blue components of specific colors. The intensities must be in the range `[0,1]`. For example, `[0.5 0.7 1]` specifies a shade of light blue.

If you are plotting one data set, specify one variable for `cvar`. For example, create a table with seven variables of random numbers. Plot the `X1`, `Y`, and `Z` variables. Vary the bubble sizes according to the `SZ` variable, and vary the colors according to the `Color1` variable.

```tbl = table(randn(50,1)-10,randn(50,1)+10,rand(50,1), ... rand(50,1),rand(50,1),rand(50,1),rand(50,1),... 'VariableNames',{'X1','X2','Y','Z','SZ','Color1','Color2'}); bubblechart3(tbl,'X1','Y','Z','SZ','Color1')```

If you are plotting multiple data sets, you can specify multiple variables for at least one of `xvar`, `yvar`, `zvar`, `sizevar`, or `cvar`. If you specify multiple variables for more than one argument, the number of variables must be the same for each of those arguments.

For example, plot the `X1` and `X2` variables on the x-axis, the `Y` variable on the y-axis, and the `Z` variable on the z-axis. Vary the bubble sizes according to the `SZ` variable. Specify the `Color1` and `Color2` variables for the colors. The resulting plot shows two sets of bubbles with the same y-coordinates, z-coordinates, and bubble sizes, but different x-coordinates and colors.

`bubblechart3(tbl,{'X1','X2'},'Y','Z','SZ',{'Color1','Color2'})`

Target axes, specified as an `Axes` object. If you do not specify the axes, MATLAB plots into the current axes, or it creates an `Axes` object if one does not exist.

### Name-Value Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: ```bubblechart3([2 1 5],[4 10 9],[1 2 3],[1 2 3],'MarkerFaceColor','red')``` creates red bubbles.

Note

The properties listed here are only a subset. For a complete list, see BubbleChart Properties.

Marker outline color, specified `'flat'`, an RGB triplet, a hexadecimal color code, a color name, or a short name. The default value of `'flat'` uses colors from the `CData` property.

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

• An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range `[0,1]`; for example, ```[0.4 0.6 0.7]```.

• A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (`#`) followed by three or six hexadecimal digits, which can range from `0` to `F`. The values are not case sensitive. Thus, the color codes `'#FF8800'`, `'#ff8800'`, `'#F80'`, and `'#f80'` are equivalent.

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

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
`'red'``'r'``[1 0 0]``'#FF0000'` `'green'``'g'``[0 1 0]``'#00FF00'` `'blue'``'b'``[0 0 1]``'#0000FF'` `'cyan'` `'c'``[0 1 1]``'#00FFFF'` `'magenta'``'m'``[1 0 1]``'#FF00FF'` `'yellow'``'y'``[1 1 0]``'#FFFF00'` `'black'``'k'``[0 0 0]``'#000000'` `'white'``'w'``[1 1 1]``'#FFFFFF'` `'none'`Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

`[0 0.4470 0.7410]``'#0072BD'` `[0.8500 0.3250 0.0980]``'#D95319'` `[0.9290 0.6940 0.1250]``'#EDB120'` `[0.4940 0.1840 0.5560]``'#7E2F8E'` `[0.4660 0.6740 0.1880]``'#77AC30'` `[0.3010 0.7450 0.9330]``'#4DBEEE'` `[0.6350 0.0780 0.1840]``'#A2142F'` Example: `[0.5 0.5 0.5]`

Example: `'blue'`

Example: `'#D2F9A7'`

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.

• An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range `[0,1]`; for example, ```[0.4 0.6 0.7]```.

• A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (`#`) followed by three or six hexadecimal digits, which can range from `0` to `F`. The values are not case sensitive. Thus, the color codes `'#FF8800'`, `'#ff8800'`, `'#F80'`, and `'#f80'` are equivalent.

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

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
`'red'``'r'``[1 0 0]``'#FF0000'` `'green'``'g'``[0 1 0]``'#00FF00'` `'blue'``'b'``[0 0 1]``'#0000FF'` `'cyan'` `'c'``[0 1 1]``'#00FFFF'` `'magenta'``'m'``[1 0 1]``'#FF00FF'` `'yellow'``'y'``[1 1 0]``'#FFFF00'` `'black'``'k'``[0 0 0]``'#000000'` `'white'``'w'``[1 1 1]``'#FFFFFF'` `'none'`Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

`[0 0.4470 0.7410]``'#0072BD'` `[0.8500 0.3250 0.0980]``'#D95319'` `[0.9290 0.6940 0.1250]``'#EDB120'` `[0.4940 0.1840 0.5560]``'#7E2F8E'` `[0.4660 0.6740 0.1880]``'#77AC30'` `[0.3010 0.7450 0.9330]``'#4DBEEE'` `[0.6350 0.0780 0.1840]``'#A2142F'` Example: `[0.3 0.2 0.1]`

Example: `'green'`

Example: `'#D2F9A7'`

Width of marker edge, specified as a positive value in point units.

Example: `0.75`

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 the `AlphaData` property to a vector the same size as the `XData` property, and set the `MarkerEdgeAlpha` 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'`.

### Topics

Introduced in R2020b