StackedLineProperties Properties
Appearance and behavior of individual lines in stacked plot
StackedLineProperties
properties control the appearance and
behavior of individual lines in a stacked plot. In a stacked plot, you
can plot the variables of a table or timetable, or the columns of a matrix, in separate
y-axes, stacked vertically. By changing property values, you can modify
certain aspects of the stacked plot.
The stackedplot
function returns a
StackedLineChart
object. In turn, this object has an array of
StackedLineProperties
objects, named LineProperties
.
To set properties of an individual line, index into LineProperties
and
access properties of the corresponding object.
You can use dot notation to query and set properties. For
example, change the third plot to a scatter plot using its PlotType
property.
T = readtable("outages.csv"); s = stackedplot(T); c = s.LineProperties(3).PlotType s.LineProperties(3).PlotType = "scatter";
If you plot multiple lines in one y-axis, then you can specify
different line property values for each line in that y-axis. For example,
plot one table variable in the first y-axis of a stacked plot and two
table variables in the second y-axis. Specify a different plot type for
each line in the second y-axis by specifying
s.LineProperties(2).PlotType
as a string array.
T = array2table(magic(9)); s = stackedplot(T,{"Var1",["Var2" "Var3"]}); s.LineProperties(1).PlotType = "stairs"; s.LineProperties(2).PlotType = ["scatter","plot"];
Line Properties
Line color, specified as an RGB triplet, a three-column matrix of RGB triplets, a hexadecimal color code, or one of the color options listed in the first table.
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 string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, 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 the hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"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 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 |
---|---|
Before R2025a: Most plots use these colors by default. |
|
|
|
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))
.
Note: If you plot multiple lines in one
y-axis, then you can specify Color
as a
three-column matrix of RGB triplets that specify a different color for each line. For
example, if there are two lines in a y-axis. then you can specify
Color
as [1 0 0]
(to turn both lines red) or as
[1 0 0; 0 0 1]
(to turn the first line red and the second line
blue).
Example: s.LineProperties(1).Color = "blue";
Example: s.LineProperties(2).Color = [0 0 1];
Example: s.LineProperties(3).Color = "#0000FF";
Example: s.LineProperties(4).Color = [1 0 0; 0 0 1];
if the fourth
y-axis has two lines.
Line style, specified as one of the options listed in this table.
Line Style | Description | Resulting Line |
---|---|---|
"-" | Solid line |
|
"--" | Dashed line |
|
":" | Dotted line |
|
"-." | Dash-dotted line |
|
"none" | No line | No line |
Note: If you plot multiple lines in one
y-axis, then you can specify LineStyle
as a
string array or cell array of character vectors that specify a different option for each
line.
Example: s.LineProperties(1).LineStyle = "-";
Example: s.LineProperties(3).LineStyle = ["-",":"];
if the third
y-axis has two lines.
Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.
The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
Note: If you plot multiple lines in one
y-axis, then you can specify LineWidth
as a
vector that specifies a different width for each line.
Example: s.LineProperties(1).LineWidth = 1.0;
Example: s.LineProperties(3).LineWidth = [1.5 3.0];
if the third
y-axis has two lines.
Marker symbol, specified as one of the values listed in this table. By default, the object does not display markers. Specifying a marker symbol adds markers at each data point or vertex.
Marker | Description | Resulting Marker |
---|---|---|
"o" | Circle |
|
"+" | Plus sign |
|
"*" | Asterisk |
|
"." | Point |
|
"x" | Cross |
|
"_" | Horizontal line |
|
"|" | Vertical line |
|
"square" | Square |
|
"diamond" | Diamond |
|
"^" | Upward-pointing triangle |
|
"v" | Downward-pointing triangle |
|
">" | Right-pointing triangle |
|
"<" | Left-pointing triangle |
|
"pentagram" | Pentagram |
|
"hexagram" | Hexagram |
|
"none" | No markers | Not applicable |
Note: If you plot multiple lines in one
y-axis, then you can specify Marker
as a
string array or cell array of character vectors that specify a different marker for each
line.
Example: s.LineProperties(1).Marker = "+";
Example: s.LineProperties(3).Marker = ["^","v"];
if the third
y-axis has two lines.
Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.
Note: If you plot multiple lines in one
y-axis, then you can specify MarkerSize
as a
vector of positive values that specify a different marker size for each line.
Example: s.LineProperties(1).MarkerSize = 3.0;
Example: s.LineProperties(3).MarkerSize = [10 16];
if the third
y-axis has two lines.
Marker outline color, specified as "none"
, an RGB triplet, a
hexadecimal color code, or one of the color options listed in the first table.
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 string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, 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 the hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"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 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 |
---|---|
Before R2025a: Most plots use these colors by default. |
|
|
|
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))
.
Note: If you plot multiple lines in one
y-axis, then you can specify MarkerEdgeColor
as a three-column matrix of RGB triplets that specify a different marker outline color
for each line. For example, if there are two lines in a y-axis.
then you can specify MarkerEdgeColor
as [1 0 0]
(to outline markers for both lines with red) or as [1 0 0; 0 0 1]
(to
outline markers for the first line with red and markers for the second line with
blue).
Example: s.LineProperties(1).MarkerEdgeColor =
"blue";
Example: s.LineProperties(2).MarkerEdgeColor = [0 0
1];
Example: s.LineProperties(3).MarkerEdgeColor =
"#0000FF";
Example: s.LineProperties(4).MarkerEdgeColor = [1 0 0; 0 0 1];
if
the fourth y-axis has two lines.
Marker fill color, specified as "none"
, an RGB triplet, a
hexadecimal color code, or one of the color options listed in the first table.
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 string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, 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 the hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"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 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 |
---|---|
Before R2025a: Most plots use these colors by default. |
|
|
|
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))
.
Note: If you plot multiple lines in one
y-axis, then you can specify MarkerFaceColor
as a three-column matrix of RGB triplets that specify a different marker fill color for
each line. For example, if there are two lines in a y-axis. then
you can specify MarkerFaceColor
as [1 0 0]
(to
fill markers for both lines with red) or as [1 0 0; 0 0 1]
(to fill
markers for the first line with red and markers for the second line with blue).
Example: s.LineProperties(1).MarkerFaceColor =
"blue";
Example: s.LineProperties(2).MarkerFaceColor = [0 0
1];
Example: s.LineProperties(3).MarkerFaceColor =
"#0000FF";
Example: s.LineProperties(4).MarkerFaceColor = [1 0 0; 0 0 1];
if
the fourth y-axis has two lines.
Plot type, specified as "plot"
, "stairs"
,
"scatter"
, or a string array or cell array of character
vectors.
If you plot multiple lines in one y-axis, then you can specify
a different plot type for each line by specifying PlotType
as a
string array or cell array of character vectors.
Example: s.LineProperties(1).PlotType = "scatter";
Example: s.LineProperties(3).PlotType = ["scatter","stairs"];
if
the third y-axis has two lines.
Version History
Introduced in R2018b
See Also
Functions
Properties
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)