Main Content

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

expand all

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 from 0 to F. 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 hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"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 applicableNot applicableNot applicableNo color

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

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

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 StyleDescriptionResulting Line
"-"Solid line

Sample of solid line

"--"Dashed line

Sample of dashed line

":"Dotted line

Sample of dotted line

"-."Dash-dotted line

Sample of dash-dotted line, with alternating dashes and dots

"none"No lineNo 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.

MarkerDescriptionResulting Marker
"o"Circle

Sample of circle marker

"+"Plus sign

Sample of plus sign marker

"*"Asterisk

Sample of asterisk marker

"."Point

Sample of point marker

"x"Cross

Sample of cross marker

"_"Horizontal line

Sample of horizontal line marker

"|"Vertical line

Sample of vertical line marker

"square"Square

Sample of square marker

"diamond"Diamond

Sample of diamond marker

"^"Upward-pointing triangle

Sample of upward-pointing triangle marker

"v"Downward-pointing triangle

Sample of downward-pointing triangle marker

">"Right-pointing triangle

Sample of right-pointing triangle marker

"<"Left-pointing triangle

Sample of left-pointing triangle marker

"pentagram"Pentagram

Sample of pentagram marker

"hexagram"Hexagram

Sample of hexagram marker

"none"No markersNot 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 from 0 to F. 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 hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"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 applicableNot applicableNot applicableNo color

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

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

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 from 0 to F. 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 hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"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 applicableNot applicableNot applicableNo color

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

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

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