This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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

expand all

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

expand all

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

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

expand all

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.

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'}

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.

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

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.

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.

Display of grid lines, specified as 'on' or 'off'.

Line

expand all

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 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.

RGB TripletHexadecimal Color CodeAppearance
[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'

Line style, specified as one of the options listed in this table.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

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.

Markers

expand all

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.

ValueDescription
'o'Circle
'+'Plus sign
'*'Asterisk
'.'Point
'x'Cross
'square' or 's'Square
'diamond' or 'd'Diamond
'^'Upward-pointing triangle
'v'Downward-pointing triangle
'>'Right-pointing triangle
'<'Left-pointing triangle
'pentagram' or 'p'Five-pointed star (pentagram)
'hexagram' or 'h'Six-pointed star (hexagram)
'none'No markers

Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.

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 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.

RGB TripletHexadecimal Color CodeAppearance
[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 '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 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.

RGB TripletHexadecimal Color CodeAppearance
[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

expand all

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.

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

expand all

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};

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

expand all

Size and location, including the labels and a margin, specified as a four-element vector of the form [left bottom width height]. By default, MATLAB measures the values in units normalized to the container. To change the units, set the Units property. The default value of [0 0 1 1] includes the whole interior of the container.

  • The left and bottom elements define the distance from the lower left corner of the container (typically a figure, panel, or tab) to the lower left corner of the outer position boundary.

  • The width and height elements are the outer position boundary dimensions.

These figures show the areas defined by the OuterPosition values (blue) and the Position values (red).

2-D View of Axes3-D View of Axes

For more information on the axes position, see Control Axes Layout.

Inner size and position 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 inner position does not include the title or axis labels.

  • The left and bottom elements define the distance from the lower left corner of the container to the lower left corner of the plot.

  • The width and height elements are the dimensions.

Size and location, excluding a margin for the labels, specified as a four-element vector of the form [left bottom width height]. By default, MATLAB measures the values in units normalized to the container. To change the units, set the Units property.

  • The left and bottom elements define the distance from the lower left corner of the container (typically a figure, panel, or tab) to the lower left corner of the position boundary.

  • The width and height elements are the position boundary dimensions. For axes in a 3-D view, the Position property is the smallest rectangle that encloses the axes.

If you want to specify the position and account for the text around the axes, then set the OuterPosition property instead. These figures show the areas defined by the OuterPosition values (blue) and the Position values (red).

2-D View of Axes3-D View of Axes

For more information on the axes position, see Control Axes Layout.

Active position property during resize operation, specified as one of these values:

  • 'outerposition' — Hold the OuterPosition property constant.

  • 'innerposition' — Hold the InnerPosition property constant.

  • 'position' — Hold the Position property constant.

A figure can change size if you interactively resize it or during a printing or exporting operation.

Position units, specified as one of these values.

UnitsDescription
'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:

  • Character width = width of letter x.

  • Character height = distance between the baselines of two lines of text.

'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.

  • On Windows systems, a pixel is 1/96th of an inch.

  • On Macintosh systems, a pixel is 1/72nd of an inch.

  • On Linux® systems, the size of a pixel is determined by your system resolution.

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.

Interactivity

expand all

State of visibility, specified as one of these values:

  • 'on' — Display the object.

  • 'off' — Hide the object without deleting it. You still can access the properties of an invisible object.

Parent/Child

expand all

Parent, specified as a Figure, Panel, or Tab object. For more information, see Figure Properties, Panel Properties, or Tab Properties.

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 to the UI by another function. Set the HandleVisibility 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.

Introduced in R2018b