Main Content

stackedplot.GydF4y2Ba

具有常见x轴的若干变量的堆叠图GydF4y2Ba

描述GydF4y2Ba

例GydF4y2Ba

stackedplot(GydF4y2Batbl)GydF4y2Ba情节S.the variables of a table or timetable in a stacked plot, up to a maximum of 25 variables. The function plots the variables in separateyGydF4y2Ba-axes, stacked vertically. The variables share a commonXGydF4y2Ba-轴。GydF4y2Ba

  • 如果GydF4y2Batbl是一个表,那么函数会对行号绘制变量。GydF4y2Ba

  • 如果GydF4y2Batbl是时间表,那么该函数会对行时间绘制变量。GydF4y2Ba

该GydF4y2Bastackedplot.GydF4y2Ba函数绘制所有数字,逻辑,分类,日期时间和持续时间变量GydF4y2Batbl,并忽略具有任何其他数据类型的表变量。GydF4y2Ba

例GydF4y2Ba

stackedplot(GydF4y2Batbl那GydF4y2Bavars)GydF4y2Ba仅绘制所指定的表或时间表变量GydF4y2Bavars。GydF4y2Ba

stackedplot(GydF4y2Ba___GydF4y2Ba那'XVariable',Xvar)GydF4y2BaS.pecifies the table variable that provides theXGydF4y2Ba- 价值for the stacked plot. This syntax supports only tables, and not timetables.

例GydF4y2Ba

stackedplot(GydF4y2BaXGydF4y2Ba那GydF4y2BayGydF4y2Ba)GydF4y2Ba绘制列GydF4y2BayGydF4y2Ba与载体GydF4y2BaXGydF4y2Ba最多25列。GydF4y2Ba

stackedplot(GydF4y2BayGydF4y2Ba)GydF4y2Ba绘制列GydF4y2BayGydF4y2Ba与他们的行号。该GydF4y2BaXGydF4y2Ba- XIS比例范围从1到行数GydF4y2BayGydF4y2Ba。GydF4y2Ba

stackedplot(GydF4y2Ba___GydF4y2Ba那GydF4y2BaLineSpec)GydF4y2Ba设置线条样式,标记符号和颜色。您可以使用此语法与任何先前语法中的任何输入参数一起使用。GydF4y2Ba

例GydF4y2Ba

stackedplot(GydF4y2Ba___GydF4y2Ba那GydF4y2Ba名称,价值GydF4y2Ba)GydF4y2Ba使用一个或多个设置堆叠曲线的属性GydF4y2Ba名称,价值GydF4y2Ba对论点。有关属性列表,请参阅GydF4y2Bastackedlinechart属性GydF4y2Ba。使用这个选项的任何输入参数combinations in the previous syntaxes. Name-value pair settings apply to all the plots in the stacked plot. Enclose each property name in quotes.

stackedplot(GydF4y2Ba父母GydF4y2Ba那GydF4y2Ba___GydF4y2Ba)GydF4y2BaCR.eates the stacked plot in the figure, panel, or tab specified by父母GydF4y2Ba。选项GydF4y2Ba父母GydF4y2BaCan precede any of the input argument combinations in the previous syntaxes.

例GydF4y2Ba

S.GydF4y2Ba= stackedplot(___GydF4y2Ba)GydF4y2Ba返回A.GydF4y2BaStackedLineChart目的。you can useS.GydF4y2Ba至Change properties of the stacked plot after you have created it. For a list of properties, seestackedlinechart属性GydF4y2Ba。GydF4y2Ba

例子GydF4y2Ba

全部收缩GydF4y2Ba

Read data from a spreadsheet to a table. Then convert the table to a timetable. The first variable that contains dates and times,OutageTime那provides the row times for the timetable. Display the first five rows.

tbl = readtable('outages.csv');tbl = table2timetable(tbl);头(TBL,5)GydF4y2Ba
ans =.GydF4y2Ba5×5时间表GydF4y2BaOutageTime地区损失客户恢复时间_____________________________________________________________________________________________________________________________07 {'冬季风暴'} 2003-01-23 00:49 {'southeast'} 530.14 2.1204E + 05 Nat {'冬季风暴'} 2003-02-07 21:15 {'southeast'} 289.4 1.4294E + 05 2003-02-17 08:14 {'冬季风暴'2004-04-06 05:44 {'{West'} 434.81 3.4037E + 05 2004-04-06 06:10 {'设备故障'} 2002-03-16 06:18 {'MIDWEST'} 186.44 2.1275E +05 2002-03-18 23:23 {'严重风暴'}GydF4y2Ba

对时间表进行排序,以便其行时间按顺序排列。时间表的行时间不需要按顺序。但是,如果您使用的行时间是GydF4y2BaXGydF4y2Ba- 绘图的轴,那么最好通过其行时间来确保时间表排序。GydF4y2Ba

tbl = sortrows(tbl); head(tbl,5)
ans =.GydF4y2Ba5×5时间表GydF4y2BaOutageTime地区客户流失RestorationTime原因________________ _____________ ______ __________ ________________ ________________ 2002-02-01 12:18 { '西南'} 458.98 1.8202e + 06 2002年2月7日16:50 { '暴风雪'} 2002-03-05 17:53 {'midwest'} 96.563 2.8666E + 05 2002-03-10 14:41 {'WINE'} 2002-03-16 06:18 {'MIDWEST'} 186.44 2.1275E + 05 2002-03-18 23:23 {'严重风暴'}2002-03-26 01:59 {'MidWest' } 388.04 5.6422e+05 2002-03-28 19:55 {'winter storm'} 2002-04-20 16:46 {'MidWest' } 23141 NaN NaT {'unknown' }

Create a stacked plot of data fromtbl。行时间,GydF4y2BaOutageTime那provide the values along theXGydF4y2Ba-轴。该GydF4y2Bastackedplot.GydF4y2Bafunction plots the values from theLoss那GydF4y2BaCustomers那and恢复时间GydF4y2Bavariables, with each variable plotted along its own y-axis. However, the plot does not include the地区GydF4y2BaandCause变量,因为它们包含无法绘制的数据。GydF4y2Ba

stackedplot(tbl)

Create a table from patient data. Display the first three rows.

tbl = readtable('患者xls'GydF4y2Ba);头(TBL,3)GydF4y2Ba
ans =.GydF4y2Ba3×10表GydF4y2BaLastName Gender Age Location Height Weight Smoker Systolic Diastolic SelfAssessedHealthStatus ____________ __________ ___ _____________________________ ______ ______ ______ ________ _________ ________________________ {'Smith' } {'Male' } 38 {'County General Hospital' } 71 176 true 124 93 {'Excellent'} {'Johnson' } {'Male' } 43 {'VA Hospital' } 69 163 false 109 77 {'Fair' } {'Williams'} {'Female'} 38 {'St. Mary's Medical Center'} 64 131 false 125 83 {'Good' }

Plot only four of the variables from the table.

stackedplot(tbl,{'Height'那GydF4y2Ba'重量'GydF4y2Ba那GydF4y2Ba'收缩'GydF4y2Ba那GydF4y2Ba'Diastolic'})GydF4y2Ba

Create a timetable and display its first three rows.

tbl = readtable('outages.csv');tbl = table2timetable(tbl);tbl = sortrows(tbl); head(tbl,3)
ans =.GydF4y2Ba3×5 timetableOutageTime地区客户流失RestorationTime原因________________ _____________ ______ __________ ________________ ________________ 2002-02-01 12:18 { '西南'} 458.98 1.8202e + 06 2002年2月7日16:50 { '暴风雪'} 2002-03-05 17:53 {'midwest'} 96.563 2.8666E + 05 2002-03-10 14:41 {'WINE'} 2002-03-16 06:18 {'MIDWEST'} 186.44 2.1275E + 05 2002-03-18 23:23 {'严重风暴'}GydF4y2Ba

Reorder the variables by specifying them in an order that differs from their order in the table. For example,恢复时间GydF4y2Bais the last variable in the timetable that can be plotted. By default,stackedplot.GydF4y2Baplaces it at the bottom of the plot. But you can reorder the variables to put恢复时间GydF4y2Baat the top.

stackedplot(tbl,{'RestorationTime'那GydF4y2Ba'Loss'那GydF4y2Ba'顾客'GydF4y2Ba})GydF4y2Ba

该R.e are also other ways to reorder the variables.

  • 通过表中的数字顺序指定它们:GydF4y2BaStackedplot(TBL,[4 2 3]);GydF4y2Ba

  • 返回A.GydF4y2BaStackedLineChart对象并重新排序其值GydF4y2Ba显示variables.GydF4y2Baproperty:s = stackedplot(tbl);s.displayvariables = {'reasoriontime','丢失','客户}GydF4y2Ba

使用患者数据的子集创建一个表,使用GydF4y2Ba重量GydF4y2Ba那GydF4y2BaSystolic那andDiastolicvariables.

加载GydF4y2BapatientsTBL =桌(重量,收缩,舒张);头(TBL,3)GydF4y2Ba
ans =.GydF4y2Ba3×3表GydF4y2Ba重量Systolic Diastolic ______ ________ _________ 176 124 93 163 109 77 131 125 83

创建一个堆叠的情节GydF4y2BaSystolicandDiastolic情节ted using the sameyGydF4y2Ba-轴。To plot variables together, specify them within a nested cell array.

vars = {{GydF4y2Ba'收缩'GydF4y2Ba那GydF4y2Ba'Diastolic'},GydF4y2Ba'重量'GydF4y2Ba}GydF4y2Ba
vars =GydF4y2Ba1×2个单元阵列GydF4y2Ba{1x2 cell} {'prefe'}GydF4y2Ba
stackedplot(tbl,vars)

创建数字矩阵和数字矢量。GydF4y2Ba

X =[0:4:20]
X =GydF4y2Ba1×60 4 8 12 16 20GydF4y2Ba
y = randi(100,6,3)GydF4y2Ba
y=6×3GydF4y2Ba82 28 96 91 55 49 13 96 81 92 97 15 64 16 43 10 98 92GydF4y2Ba

使用堆叠的绘图使用GydF4y2BaXGydF4y2BaandyGydF4y2Ba。GydF4y2Ba

stackedplot(X那y)GydF4y2Ba

加载具有一套天气测量的时间表。Display its first three rows.

加载GydF4y2Ba户外GydF4y2Ba户外(1:3,:)GydF4y2Ba
ans =.GydF4y2Ba3×3 timetableTime Humidity TemperatureF PressureHg ___________________ ________ ____________ __________ 2015-11-15 00:00:24 49 51.3 29.61 2015-11-15 01:30:24 48.9 51.5 29.61 2015-11-15 03:00:24 48.9 51.5 29.61

创建一个堆叠的绘图。指定标题和标签GydF4y2BayGydF4y2Ba使用名称值对参数的-axes。您可以使用名称 - 值对从其默认值更改任何属性。(另请注意,您可以使用学位符号使用GydF4y2BaChar(176)。)GydF4y2Ba

DegleSymbol = Char(176);newylabels = {GydF4y2Ba'RH (%)'那['t('GydF4y2BaDegleSymbol.GydF4y2Ba'F)'],'p(以hg)'GydF4y2Ba};stackedplot(户外,GydF4y2Ba'Title'那GydF4y2Ba'天气数据'GydF4y2Ba那GydF4y2Ba'displaylabels'GydF4y2Ba,newylabels)GydF4y2Ba

该GydF4y2Bastackedplot.GydF4y2Ba函数返回A.GydF4y2BaStackedLineChart目的。您可以使用它来为所有绘图设置相同的属性值,或为单个绘图设置不同的属性值。在该示例中,首先更改堆叠图中的所有绘图的线宽。然后,使用GydF4y2Baplottype.GydF4y2Baproperty of individual plots, so that the stacked plot has a line plot, scatter plot, and stair plot.

加载具有一套天气测量的时间表。GydF4y2Ba

加载GydF4y2Ba户外GydF4y2Ba户外(1:3,:)GydF4y2Ba
ans =.GydF4y2Ba3×3 timetableTime Humidity TemperatureF PressureHg ___________________ ________ ____________ __________ 2015-11-15 00:00:24 49 51.3 29.61 2015-11-15 01:30:24 48.9 51.5 29.61 2015-11-15 03:00:24 48.9 51.5 29.61

创建一个堆叠的绘图并返回一个GydF4y2BaStackedLineChart目的。GydF4y2Ba

s = stackedplot(户外)GydF4y2Ba

S.= StackedLineChart with properties: SourceTable: [51x3 timetable] DisplayVariables: {'Humidity' 'TemperatureF' 'PressureHg'} Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 Show all properties

该目的provides access to many properties that apply to all of the plots. For example, you can useS.。LineWidth至make the lines wider.

S.。LineWidth = 2;

该对象还提供对可以用于修改行的对象数组的访问权限GydF4y2BayGydF4y2Ba用于单个图的轴。访问各个行的属性,使用GydF4y2BaS.LineProperties.GydF4y2Ba。For each plot, you can specify a different line style, marker, plot type, and so on.

S.LineProperties.GydF4y2Ba
ans =.GydF4y2Ba3×1对象GydF4y2Ba3x1 stackedlineproperties数组与属性:颜色markerfaceColor markeredgecolor linestyle linewwidth标记标记标记plottypeGydF4y2Ba

Change the second plot to a scatter plot, and the third plot to a stair plot, using theplottype.GydF4y2Ba属性。GydF4y2Ba

S.LineProperties.(2).PlotType ='scatter';S.LineProperties.(3).PlotType ='楼梯'GydF4y2Ba;GydF4y2Ba

您还可以访问个人GydF4y2BayGydF4y2Ba-axes through thes.axesproperties.GydF4y2Ba属性。GydF4y2Ba

s.axesproperties.GydF4y2Ba
ans =.GydF4y2Ba3×1对象GydF4y2Ba3x1 Stackedaxesproperties array具有属性:Ylimits LegendLabels LegendLocation传奇传奇GydF4y2Ba

输入参数GydF4y2Ba

全部收缩GydF4y2Ba

输入表或时间表。GydF4y2Ba

输入表中的变量,指定为字符向量,字符串阵列,数字阵列或逻辑阵列的单元格数组。GydF4y2Ba

如果GydF4y2Bavarsis a cell array, it also can be a nested cell array. Thestackedplot.GydF4y2Ba函数绘制相同的嵌套单元中指定的所有变量GydF4y2BayGydF4y2Ba-轴。GydF4y2Ba

Table variable that containsXGydF4y2Ba- 价值那S.pecified as a character vector, string scalar, integer, or logical array.

您可以指定GydF4y2BaXvaronly when the input argumenttbl是一个表,不是时间表。GydF4y2Ba

XGydF4y2Ba- 价值那S.pecified as a numeric, datetime, duration, or logical vector. The length ofXGydF4y2Ba必须等于行的行数GydF4y2BayGydF4y2Ba。GydF4y2Ba

yGydF4y2Ba- 价值那S.pecified as a numeric, datetime, duration, categorical, or logical array. Thestackedplot.GydF4y2Ba函数在单独的情况下绘制每个列GydF4y2BayGydF4y2Ba-轴。GydF4y2Ba

线型,标记和颜色,指定为包含符号的字符向量或字符串。符号可以以任何顺序出现。您无需指定所有三种特征(线条样式,标记和颜色)。例如,如果省略了线条样式并指定标记,则绘图仅显示标记和无行。GydF4y2Ba

Example:' - 要么'GydF4y2Ba是一个带圆形标记的红色虚线GydF4y2Ba

线条风格GydF4y2Ba 描述GydF4y2Ba
-GydF4y2Ba Solid line
--GydF4y2Ba 虚线GydF4y2Ba
:GydF4y2Ba 虚线GydF4y2Ba
-。GydF4y2Ba DASH-DOT线GydF4y2Ba
标记GydF4y2Ba 描述GydF4y2Ba
'o' 圈GydF4y2Ba
'+' Plus sign
'*' 星号GydF4y2Ba
'。'GydF4y2Ba Point
'X'GydF4y2Ba Cross
'_' 水平线GydF4y2Ba
'|' Vertical line
'GydF4y2Ba 广场GydF4y2Ba
'D'GydF4y2Ba 钻石GydF4y2Ba
'^' Upward-pointing triangle
'v'GydF4y2Ba 向下指向三角形GydF4y2Ba
'>' 右三角形GydF4y2Ba
'<' 左侧三角形GydF4y2Ba
'P'GydF4y2Ba Pentagram
'H'GydF4y2Ba 六芒星GydF4y2Ba
颜色GydF4y2Ba 描述GydF4y2Ba

yGydF4y2Ba

黄色GydF4y2Ba

mGydF4y2Ba

magenta

CGydF4y2Ba

青色GydF4y2Ba

R.GydF4y2Ba

红GydF4y2Ba

GGydF4y2Ba

绿色GydF4y2Ba

B.GydF4y2Ba

蓝色GydF4y2Ba

W.GydF4y2Ba

白色GydF4y2Ba

K.GydF4y2Ba

B.lack

父容器,指定为aGydF4y2Ba数字GydF4y2Ba那GydF4y2BaPanel那GydF4y2BaTab那GydF4y2BaTiledChartLayout那or网格布局GydF4y2Ba目的。GydF4y2Ba

名称值对参数GydF4y2Ba

指定可选的逗号分离对GydF4y2Ba名称,价值GydF4y2Baarguments.名称GydF4y2Ba是参数名称和GydF4y2BaValueis the corresponding value.名称GydF4y2Ba必须出现在引号内。您可以以任何顺序指定多个名称和值对参数GydF4y2Ba名称1,Value1,...,NameN,ValueN。GydF4y2Ba

Example:'Marker','o','MarkerSize',10

该S.tacked chart line properties listed here are only a subset common to all stacked plots, whether the data source is a table or array. For a complete list, seestackedlinechart属性GydF4y2Ba。GydF4y2Ba

线颜色,指定为RGB三联网,十六进制颜色代码或第一个表中列出的颜色选项之一。GydF4y2Ba

有关自定义颜色,请指定RGB三态或十六进制颜色代码。GydF4y2Ba

  • 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]GydF4y2Ba;for example,[0.4 0.6 0.7]。GydF4y2Ba

  • 十六进制颜色代码是字符向量或以哈希符号开头的字符串标量(GydF4y2Ba#GydF4y2Ba)followed by three or six hexadecimal digits, which can range from0.GydF4y2Ba至GydF4y2BaFGydF4y2Ba。该values are not case sensitive. Thus, the color codes'#FF8800'那GydF4y2Ba'#ff8800'GydF4y2Ba那GydF4y2Ba'#F80'那and'#f80'GydF4y2Ba是等同的。GydF4y2Ba

此外,您可以指定一些常见的颜色B.yname. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

颜色名称GydF4y2Ba Short Name RGB三重态GydF4y2Ba 十六进制颜色代码GydF4y2Ba Appearance
'红'GydF4y2Ba 'r'GydF4y2Ba [1 0 0] '#ff0000'GydF4y2Ba

'绿色'GydF4y2Ba 'G'GydF4y2Ba [0 1 0]GydF4y2Ba '#00ff00'GydF4y2Ba

'blue' 'B'GydF4y2Ba [0 0 1] '#0000ff'GydF4y2Ba

'cyan' 'C'GydF4y2Ba [0 1 1]GydF4y2Ba '#00ffff'GydF4y2Ba

'magenta' 'm' [1 0 1] '#ff00ff'GydF4y2Ba

'黄色'GydF4y2Ba '是'GydF4y2Ba [1 1 0]GydF4y2Ba '#ffff00'GydF4y2Ba

'黑色'GydF4y2Ba 'k' [0 0 0] '#000000'

'白色'GydF4y2Ba 'W'GydF4y2Ba [1 1]GydF4y2Ba '#ffffff'GydF4y2Ba

'没有'GydF4y2Ba 不适用GydF4y2Ba 不适用GydF4y2Ba 不适用GydF4y2Ba 没有颜色GydF4y2Ba

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB®GydF4y2Ba在许多类型的图中使用。GydF4y2Ba

RGB三重态GydF4y2Ba 十六进制颜色代码GydF4y2Ba Appearance
[0 0.4470 0.7410]GydF4y2Ba '#0072BD'

[0.8500 0.3250 0.0980]GydF4y2Ba '#d95319'GydF4y2Ba

[0.9290 0.6940 0.1250]GydF4y2Ba '#EDB120'

[0.4940 0.1840 0.5560] '#7e2f8e'GydF4y2Ba

[0.4660 0.6740 0.1880]GydF4y2Ba '#77AC30'

[0.3010 0.7450 0.9330] '#4DBEEE'

[0.6350 0.0780 0.1840] '#a2142f'GydF4y2Ba

Example:'blue'

Example:[0 0 1]

Example:'#0000ff'GydF4y2Ba

线条样式,指定为此表中列出的选项之一。GydF4y2Ba

线条风格GydF4y2Ba 描述GydF4y2Ba 结果线GydF4y2Ba
' - 'GydF4y2Ba Solid line

' - 'GydF4y2Ba 虚线GydF4y2Ba

':' 虚线GydF4y2Ba

' - 。'GydF4y2Ba 划线GydF4y2Ba

'没有'GydF4y2Ba No line No line

行宽那S.pecified 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.

线宽不能比像素的宽度更薄。如果将线宽设置为低于系统上像素宽度的值,则该行将显示为一个像素宽。GydF4y2Ba

标记S.ymB.ol, 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.

Value 描述GydF4y2Ba
'o' 圈GydF4y2Ba
'+' Plus sign
'*' 星号GydF4y2Ba
'。'GydF4y2Ba Point
'X'GydF4y2Ba Cross
'_' 水平线GydF4y2Ba
'|' Vertical line
'广场'GydF4y2Baor'GydF4y2Ba 广场GydF4y2Ba
'钻石'GydF4y2Baor'D'GydF4y2Ba 钻石GydF4y2Ba
'^' Upward-pointing triangle
'v'GydF4y2Ba 向下指向三角形GydF4y2Ba
'>' 右三角形GydF4y2Ba
'<' 左侧三角形GydF4y2Ba
'pentagram'GydF4y2Baor'P'GydF4y2Ba Five-pointed star (pentagram)
'hexagram'or'H'GydF4y2Ba 六角星(六角形)GydF4y2Ba
'没有'GydF4y2Ba No markers

标记尺寸,指定为点的正值,其中1点= 1/72英寸。GydF4y2Ba

输出参数GydF4y2Ba

全部收缩GydF4y2Ba

StackedLineChart对象,这是一个GydF4y2BaS.tandalone visualization。采用GydF4y2BaS.GydF4y2Ba在创建它后将属性设置在堆叠的绘图上。GydF4y2Ba

更多关于GydF4y2Ba

全部收缩GydF4y2Ba

Standalone Visualization

独立的可视化是一种专为特殊目的而独立地从其他图表工作的图表。与其他图表不同GydF4y2Ba情节GydF4y2Baand冲浪GydF4y2Ba,独立的可视化具有内置于其中的预配置轴对象,并且某些自定义不可用。独立的可视化也具有这些特征:GydF4y2Ba

  • It cannot be combined with other graphics elements, such as lines, patches, or surfaces. Thus, the保持GydF4y2Ba不支持命令。万博1manbetxGydF4y2Ba

  • 该GydF4y2BaGCA.GydF4y2Bafunction can return the chart object as the current axes.

  • you can pass the chart object to many MATLAB functions that accept an axes object as an input argument. For example, you can pass the chart object to the标题GydF4y2Ba功能。GydF4y2Ba

Tips

  • 要交互方式探索堆叠绘图中的数据,请使用这些功能。GydF4y2Ba

    • Zoom — Use the scroll wheel to zoom.

    • PAN - 单击并将堆叠的绘图拖动到平移GydF4y2BaXGydF4y2Ba- 价值。GydF4y2Ba

    • 数据光标 - 将悬停在显示位置GydF4y2BayGydF4y2Ba- 每个情节的值。GydF4y2Ba

在R2018B中介绍GydF4y2Ba