StackedLineChart Properties
Stacked plot appearance and behavior
StackedLineChart
properties control the appearance and behavior
of 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.
You can use dot notation to query and set properties.
T = readtable('outages.csv'); s = stackedplot(T); c = s.Color; s.Color = 'red';
Table Data
SourceTable
— Source table
table | timetable
Source table, specified as a table or a timetable.
You can create a table from workspace variables using the table
function, or you can import data as a table using the readtable
function. You can create a timetable from workspace variables
using the timetable
function.
Note
The property is ignored and read-only when the plotted data comes from an array.
Array Data
XData
— x-values
vector
x-values, specified as a vector. The number of elements in the
vector must equal the number of rows in the value of the YData
property.
Note
The property is ignored and read-only when the plotted data comes from a table or timetable.
Example: [1:10]
Data Types: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| categorical
| datetime
| duration
YData
— y-values
array
y-values, specified as an array. The
stackedplot
function plots each column of the value of
YData
in its own y-axis.
Note
The property is ignored and read-only when the plotted data comes from a table or timetable.
Example: [1:10;5:5:50]
Data Types: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| categorical
| datetime
| duration
Stacked Plot Display
DisplayVariables
— Displayed variables
cell array of character vectors | string array | numeric array | logical array
Displayed variables, specified as a character vector, cell array of character vectors, string array, numeric array, or logical array. By setting this property you can plot a subset or a permutation of the variables in the input table or timetable.
If DisplayVariables
is a cell array, it also can be a nested cell
array. The stackedplot
function plots all the variables specified
in a nested cell in the same y-axis.
Example: s.DisplayVariables = [1 3 4]
specifies the first, third,
and fourth variables.
Example: s.DisplayVariables = {{'Temp1','Temp2'},'Pressure'}
uses
a nested cell array to specify that Temp1
and
Temp2
are plotted together.
Example: s.DisplayVariables = {{1,2},5}
specifies variables by
number and plots the first and second variables together.
DisplayLabels
— Labels for y-axes
cell array of character vectors | string array
Labels for the stacked y-axes values, specified as a cell array
of character vectors or a string array. Specify one label for each value in
DisplayVariables
. By default, the values are the same as the
values in DisplayVariables
.
If you add a value, delete a value, or rearrange the values in
DisplayVariables
, then this property updates accordingly to
maintain the pairings of values and labels.
Example: s.DisplayLabels =
{'Temperature','Humidity','Pressure'}
XVariable
— Table variable for x-axis
character vector | string | numeric scalar | logical vector
Table variable for the x-axis, specified in one of these forms:
Character vector or string indicating the name of one table variable
Numeric scalar indicating the index of one table variable
Logical vector containing one
true
element
Note
The property is ignored and read-only when the plotted data come from an array or a timetable.
XLimits
— Minimum and maximum x-axis limits
two-element vector of the form [min max]
Minimum and maximum x-axis limits, specified as a two-element
vector of the form [min max]
, where max
is greater
than min
. You can specify the limits as numeric, categorical,
datetime, or duration values. However, the type of values that you specify must match
the type of values along the axis.
You can specify both limits or you can specify one limit and let the axes
automatically calculate the other. For an automatically calculated minimum or maximum
limit, use -inf
or inf
, respectively.
Example: s.XLimits = [0 100]
Example: s.XLimits = [-inf 100]
Example: s.XLimits = [0 inf]
Data Types: double
| single
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| datetime
| duration
AxesProperties
— Properties of y-axes
array of StackedAxesProperties
objects
Properties of the y-axes, specified as an array of
StackedAxesProperties
objects. You can index into
AxesProperties
to change the y-axis properties
for one variable in the stacked plot. For more information, see StackedAxesProperties Properties.
Example: s.AxesProperties(2).YLimits = [0 10]
specifies limits for
the second plot in the stacked plot. The other plots are unaltered.
LineProperties
— Properties of lines
array of StackedLineProperties
objects
Properties of lines, specified as an array of
StackedLineProperties
objects. You can index into
LineProperties
to change the properties of a line for one variable
in the stacked plot. For more information, see StackedLineProperties Properties.
Example: s.LineProperties(3).Color = 'red'
changes the line color
of the third plot in the stacked plot. The other plots are unaltered.
GridVisible
— Display of grid lines
'on'
| on/off logical value
Display of grid lines, specified as 'on'
or
'off'
, or as numeric or logical 1
(true
) or 0
(false
). A value
of 'on'
is equivalent to true
, and
'off'
is equivalent to false
. Thus, you can use
the value of this property as a logical value. The value is stored as an on/off logical
value of type matlab.lang.OnOffSwitchState
.
Line
Color
— Line color
[0 0.4470 0.7410]
(default) | RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...
Line color, specified as 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 character vector or a string scalar that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. 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 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' |
Example: 'blue'
Example: [0 0 1]
Example: '#0000FF'
LineStyle
— Line style
'-'
(default) | '--'
| ':'
| '-.'
| 'none'
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 |
LineWidth
— Line width
0.5
(default) | positive value
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.
Markers
Marker
— Marker symbol
'none'
(default) | 'o'
| '+'
| '*'
| '.'
| ...
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 |
|
's' | Square |
|
'd' | Diamond |
|
'^' | Upward-pointing triangle |
|
'v' | Downward-pointing triangle |
|
'>' | Right-pointing triangle |
|
'<' | Left-pointing triangle |
|
'p' | Pentagram |
|
'h' | Hexagram |
|
'none' | No markers | Not applicable |
MarkerSize
— Marker size
6
(default) | positive value
Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.
MarkerEdgeColor
— Marker outline color
'none'
| RGB triplet | 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 character vector or a string scalar that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. 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 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' |
|
Example: [0.5 0.5 0.5]
Example: 'blue'
Example: '#D2F9A7'
MarkerFaceColor
— Marker fill color
'none'
(default) | RGB triplet | 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 character vector or a string scalar that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. 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 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' |
|
Example: [0.3 0.2 0.1]
Example: 'green'
Example: '#D2F9A7'
Font
FontName
— Font name
supported font name | 'FixedWidth'
Font name, specified as a supported font name or 'FixedWidth'
. To display
and print text properly, you must choose a font that your system supports. The default
font depends on your operating system and locale.
To use a fixed-width font that looks good in any locale, use 'FixedWidth'
.
The fixed-width font relies on the root FixedWidthFontName
property. Setting the root FixedWidthFontName
property causes an
immediate update of the display to use the new font.
FontSize
— Font size
8
(default) | scalar numeric value
Font size, specified as a scalar numeric value. The font size affects the title, axis labels, and tick labels. It also affects any legends associated with the axes. The font size is measured in points.
Example: s.FontSize = 12
Labels
Title
— Title of stacked plot
character vector | string scalar | numeric scalar | string array | numeric array | cell array | categorical array
Title of the stacked plot, specified as a character vector, string scalar, numeric scalar, string array, numeric array, cell array, or categorical array.
If the value of Title
is an array, then the elements of the array
are stacked vertically and displayed as the title. If the value is a cell array, then
its elements can be character vectors, strings, or numbers.
Alternatively, use the title
function to add a
title.
title('My Title')
Example: s.Title = 'A Title';
Example: s.Title = 137
Example: s.Title = {'Stacked
plot',char(datetime('now'))};
Example: s.Title = {'Stacked plot',137};
XLabel
— Text for x-axis label
character vector | string scalar | numeric scalar | string array | numeric array | cell array | categorical array
Text for x-axis label, specified as a character vector, string scalar, numeric scalar, string array, numeric array, cell array, or categorical array.
If the value of XLabel
is an array, then the elements of the
array are stacked vertically and displayed as the x-axis label. If
the value is a cell array, then its elements can be character vectors, strings, or
numbers.
Alternatively, use the xlabel
function to add an
x-axis
label.
xlabel('My x-Axis Label')
Example: s.XLabel = 'An x-axis Label';
Example: s.XLabel = 137
Example: s.XLabel = {'An x-axis
Label',char(datetime('now'))};
Example: s.XLabel = {'An x-axis Label',137};
Position
OuterPosition
— Outer size and location
[0 0 1 1]
(default) | four-element vector
Outer size and location of the plot within the parent container (typically a figure,
panel, or tab), specified as a four-element vector of the form [left bottom
width height]
.
The
left
andbottom
elements define the distance from the lower left corner of the container to the lower left corner of the plot.The
width
andheight
elements are the width and height of the rectangle that encloses the plot and the axes, including decorations such as the title and axis labels.
The default value of [0 0 1 1]
covers the whole interior of the
container. The units are normalized relative to the size of the container. To change the
units, set the Units
property.
Note
Setting this property has no effect when the parent container is a
TiledChartLayout
.
InnerPosition
— Inner size and location
four-element vector
Inner size and location of the plot within the parent container (typically a figure,
panel, or tab) specified as a four-element vector of the form [left bottom
width height]
.
The
left
andbottom
elements define the distance from the lower left corner of the container to the lower left corner of the plot.The
width
andheight
elements are the width and height of the rectangle that encloses the plot and the axes, excluding decorations such as the title and axis labels.
Note
Setting this property has no effect when the parent container is a
TiledChartLayout
.
Position
— Inner size and location
four-element vector
Inner size and location of the plot within the parent container (typically a figure,
panel, or tab) returned as a four-element vector of the form [left bottom width
height]
. This property is equivalent to the
InnerPosition
property.
Note
Setting this property has no effect when the parent container is a
TiledChartLayout
.
PositionConstraint
— Position to hold constant
'outerposition'
| 'innerposition'
Position property to hold constant when adding, removing, or changing decorations, specified as one of the following values:
'outerposition'
— TheOuterPosition
property remains constant when you add, remove, or change decorations such as a title or an axis label. If any positional adjustments are needed, MATLAB adjusts theInnerPosition
property.'innerposition'
— TheInnerPosition
property remains constant when you add, remove, or change decorations such as a title or an axis label. If any positional adjustments are needed, MATLAB adjusts theOuterPosition
property.
Note
Setting this property has no effect when the parent container is a
TiledChartLayout
.
Units
— Position units
'normalized'
(default) | 'inches'
| 'centimeters'
| 'points'
| 'pixels'
| 'characters'
Position units, specified as one of these values.
Units | Description |
---|---|
'normalized' (default) | Normalized with respect to the container, which is typically the
figure or a panel. The lower left corner of the container maps to
(0,0) and the upper right corner maps to
(1,1) . |
'inches' | Inches. |
'centimeters' | Centimeters. |
'characters' | Based on the default uicontrol font of the graphics root object:
|
'points' | Typography points. One point equals 1/72 inch. |
'pixels' | Pixels. Starting in R2015b, distances in pixels are independent of your system resolution on Windows® and Macintosh systems.
|
When specifying the units as a Name,Value
pair
during object creation, you must set the Units
property
before specifying the properties that you want to use these units,
such as Position
.
Layout
— Layout options
empty LayoutOptions
array (default) | TiledChartLayoutOptions
object | GridLayoutOptions
object
Layout options, specified as a TiledChartLayoutOptions
or
GridLayoutOptions
object. This property is useful when the chart
is either in a tiled chart layout or a grid layout.
To position the chart within the grid of a tiled chart layout, set the
Tile
and TileSpan
properties on the
TiledChartLayoutOptions
object. For example, consider a 3-by-3
tiled chart layout. The layout has a grid of tiles in the center, and four tiles along
the outer edges. In practice, the grid is invisible and the outer tiles do not take up
space until you populate them with axes or charts.
This code places the chart c
in the third tile of the
grid..
c.Layout.Tile = 3;
To make the chart span multiple tiles, specify the TileSpan
property as a two-element vector. For example, this chart spans 2
rows and 3
columns of
tiles.
c.Layout.TileSpan = [2 3];
To place the chart in one of the surrounding tiles, specify the
Tile
property as 'north'
,
'south'
, 'east'
, or 'west'
.
For example, setting the value to 'east'
places the chart in the tile
to the right of the
grid.
c.Layout.Tile = 'east';
To place the chart into a layout within an app, specify this property as a
GridLayoutOptions
object. For more information about working with
grid layouts in apps, see uigridlayout
.
If the chart is not a child of either a tiled chart layout or a grid layout (for example, if it is a child of a figure or panel) then this property is empty and has no effect.
Interactivity
Visible
— State of visibility
'on'
(default) | on/off logical value
State of visibility, specified as 'on'
or 'off'
, or as
numeric or logical 1
(true
) or
0
(false
). A value of 'on'
is equivalent to true
, and 'off'
is equivalent to
false
. Thus, you can use the value of this property as a logical
value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
'on'
— Display the object.'off'
— Hide the object without deleting it. You still can access the properties of an invisible object.
Parent/Child
Parent
— Parent container
Figure
object | Panel
object | Tab
object | TiledChartLayout
object | GridLayout
object
Parent container, specified as a Figure
,
Panel
, Tab
,
TiledChartLayout
, or GridLayout
object.
HandleVisibility
— Visibility of object handle
'on'
(default) | 'off'
| 'callback'
Visibility of the object handle in the Children
property
of the parent, specified as one of these values:
'on'
— Object handle is always visible.'off'
— Object handle is invisible at all times. This option is useful for preventing unintended changes by another function. Set theHandleVisibility
to'off'
to temporarily hide the handle during the execution of that function.'callback'
— Object handle is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line. This option blocks access to the object at the command line, but permits callback functions to access it.
If the object is not listed in the Children
property of the parent, then
functions that obtain object handles by searching the object hierarchy or querying
handle properties cannot return it. Examples of such functions include the
get
, findobj
, gca
, gcf
, gco
, newplot
, cla
, clf
, and close
functions.
Hidden object handles are still valid. Set the root ShowHiddenHandles
property
to 'on'
to list all object handles regardless of
their HandleVisibility
property setting.
Version History
Introduced in R2018bR2020a: ActivePositionProperty
is not recommended
Not recommended starting in R2020a
Starting in R2020a, setting or getting ActivePositionProperty
is not
recommended. Use the PositionConstraint
property instead.
There are no plans to remove ActivePositionProperty
at this time, but the
property is no longer listed when you call the set
,
get
, or properties
functions on the chart
object.
To update your code, make these changes:
Replace all instances of
ActivePositionProperty
withPositionConstraint
.Replace all references to the
'position'
option with the'innerposition'
option.
See Also
Functions
Properties
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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)