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
Color
— Line color
[0 0.4470 0.7410]
(default) | RGB triplet | three-column matrix of RGB triplets | hexadecimal color code | "r"
| "g"
| "b"
| ...
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 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 |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[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" |
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.
LineStyle
— Line style
"-"
(default) | "--"
| ":"
| "-."
| "none"
| string array | cell array of character vectors
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.
LineWidth
— Line width
0.5
(default) | positive value | vector of positive values
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
— Marker symbol
"none"
(default) | "o"
| "+"
| "*"
| "."
| string array | cell array of character vectors | ...
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.
MarkerSize
— Marker size
6
(default) | positive value | vector of positive values
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.
MarkerEdgeColor
— Marker outline color
"none"
| RGB triplet | three-column matrix of RGB triplets | hexadecimal color code | "r"
| "g"
| "b"
| ...
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 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 |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[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" |
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.
MarkerFaceColor
— Marker fill color
"none"
(default) | RGB triplet | three-column matrix of RGB triplets | hexadecimal color code | "r"
| "g"
| "b"
| ...
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 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 |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[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" |
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.
PlotType
— Plot type
"plot"
(default) | "stairs"
| "scatter"
| string array | cell array of character vectors
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: .
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)