Scatter plot with marginal histograms
scatterhist
Plot加载样本数据。创建数据向量x
from the first column of the data matrix, which contains sepal length measurements from iris flowers. Create data vectory
从数据矩阵的第二列中,其中包含来自同一花的萼片宽度测量值。
loadfisheriris.mat;x = meas(:,1);y = meas(:,2);
Create a scatter plot and two marginal histograms to visualize the relationship between sepal length and sepal width.
散射史(x,y)
在直方图中显示垃圾箱的数据提示。当您将悬停在直方图中的垃圾箱上时,会出现数据提示。
The data tip displays the probability density function estimate of the selected bin and the lower and upper values for the bin edges.
加载样本数据。创建数据向量x
from the first column of the data matrix, which contains sepal length measurements from three species of iris flowers. Create data vectory
从数据矩阵的第二列中,其中包含来自同一花的萼片宽度测量值。
loadfisheriris.mat;x = meas(:,1);y = meas(:,2);
Create a scatter plot and six kernel density plots to visualize the relationship between sepal length and sepal width, grouped by species.
分散史(x,y,'Group',species,'Kernel','on')
The plot shows that the relationship between sepal length and width varies depending on the flower species.
加载样本数据。创建数据向量x
从数据矩阵的第一列中,其中包含来自三种不同种类的虹膜花的萼片长度测量。创建数据向量y
从数据矩阵的第二列中,其中包含来自同一花的萼片宽度测量值。
loadfisheriris.mat;x = meas(:,1);y = meas(:,2);
创建一个散点图和六个内核密度图,以可视化在三种由物种分组的虹膜花中测量的萼片长度和萼片宽度之间的关系。自定义图的外观。
分散史(x,y,'Group',species,'Kernel','on','Location','SouthEast',...'方向','out','颜色','kbr','linestyle',{“- - -”,'-.',':'},,...'行宽',[2,2,2],'Marker','+od','MarkerSize',[4,5,6]);
加载样本数据。创建数据向量x
from the first column of the data matrix, which contains sepal length measurements from three species of iris flowers. Create data vectory
从数据矩阵的第二列中,其中包含来自同一花的萼片宽度测量值。
loadfisheriris.mat;x = meas(:,1);y = meas(:,2);
Use axis handles to replace the marginal histograms with box plots.
h = scatterhist(x,y,'Group',species); holdon;clr = get(h(1),“颜色订单”); boxplot(h(2),x,species,'方向','horizontal',...'label',{'','',''},,'color',clr);Boxplot(H(3),Y,物种,'方向','horizontal',...'label', {'','',''},,'color',clr);设置(h(2:3),'XTickLabel',''); view(h(3),[270,90]);%旋转Y图axis(h(1),'auto');% Sync axesholdoff;
scatterhist
在指定的父容器中绘制加载样本数据。创建数据向量x
from the first column of the data matrix, which contains sepal length measurements from iris flowers. Create data vectory
从数据矩阵的第二列中,其中包含来自同一花的萼片宽度测量值。
loadfisheririsx = meas(:,1);y = meas(:,2);
创建一个新图形并定义两个uipanel
objects to divide the figure into two parts. In the upper half of the figure, plot the sample data usingscatterhist
. Include marginal kernel density plots grouped by species. In the lower half of the figure, plot a histogram of the sepal length measurements contained inx
.
数字hp1 = uipanel('位置',[0 .5 1 .5]);hp2 = uipanel('位置',[0 0 1 .5]);分散史(x,y,'Group',species,'Kernel','on','Parent',hp1); axes('Parent',hp2); hist(x);
x
—Sample dataSample data, specified as a vector. The data vectorsx
andy
must be the same length.
Ifx
ory
containNaN
values, thenscatterhist
:
Removes rows withNaN
values in eitherx
ory
生成散点图时两个数据向量
Removes rows withNaN
仅来自相应的值x
ory
data vector when generating the marginal histograms
数据类型:single
|双倍的
y
—Sample dataSample data, specified as a vector. The data vectorsx
andy
must be the same length.
Ifx
ory
containNaN
values, thenscatterhist
:
Removes rows withNaN
values in eitherx
ory
生成散点图时两个数据向量
Removes rows withNaN
仅来自相应的值x
ory
data vector when generating the marginal histograms
数据类型:single
|双倍的
Specify optional comma-separated pairs of姓名,Value
参数。姓名
is the argument name andValue
is the corresponding value.姓名
must appear inside quotes. You can specify several name and value pair arguments in any order asNAME1,Value1,...,Namen,Valuen
.
'Location','SouthEast','Direction','out'
specifies a plot with histograms located below and to the right of the scatter plot, with the bars directed away from the scatter plot.
'NBins'
—Number of bins for histograms'Location'
—边缘直方图的位置'西南'
(默认)|'SouthEast'
|'东北'
|'NorthWest'
地点of the marginal histograms in the figure, specified as the comma-separated pair consisting of'Location'
and one of the following.
'西南' |
Plot the histograms below and to the left of the scatter plot. |
'SouthEast' |
Plot the histograms below and to the right of the scatter plot. |
'东北' |
Plot the histograms above and to the right of the scatter plot. |
'NorthWest' |
Plot the histograms above and to the left of the scatter plot. |
例子:'Location','SouthEast'
'方向'
—Direction of marginal histograms'in'
(默认)|'out'
边缘直方图的方向,指定为逗号分隔对'方向'
and one of the following.
'in' |
Plot the histograms with the bars directed toward the scatter plot. |
'out' |
用远离散点图的条形图绘制直方图。 |
例子:'方向','out'
'Group'
—Grouping variableGrouping variable, specified as the comma-separated pair consisting of'Group'
以及一个分类数组,逻辑或数字向量,字符数组,字符串数组或字符向量的单元格数组。分组变量中的每个唯一值都定义了一个组。
For example, ifGender
is a cell array of character vectors with values'Male'
and'Female'
, you can useGender
作为分组变量绘制数据按性别.
The number of rows in the grouping variable must be equal to the length ofx
.
例子:'Group',Gender
数据类型:分类
|single
|双倍的
|logical
|char
|细绳
|cell
'PlotGroup'
—分组图指示器'on'
|'离开'
分组图指示器, specified as the comma-separated pair consisting of'PlotGroup'
and one of the following.
'on' |
Display grouped histograms or grouped kernel density plots. This is the default if aGroup parameter is specified. |
'离开' |
Display histograms or kernel density plots of the whole data set. This is the default if aGroup parameter is not specified. |
例子:'PlotGroup','off'
'Style'
—Histogram display style'楼梯'
|'bar'
直方图显示样式,指定为逗号分隔对'PlotGroup'
and one of the following.
'楼梯' |
Display a stairstep plot that shows the outline of the histogram without filling the bars. This is the default if you specify a grouping variable that contains more than one group. |
'bar' |
显示直方图栏图。如果指定仅包含一个组或情节组 is specified as'离开' . |
例子:'Style','bar'
'Kernel'
—Kernel density plot indicator'离开'
(默认)|'on'
|'overlay'
Kernel density plot indicator, specified as the comma-separated pair consisting of'Kernel'
and one of the following.
'离开' |
将边缘分布显示为直方图。 |
'on' |
Display the marginal distributions as kernel density plots. |
'overlay' |
显示边缘分布作为核密度图覆盖到直方图上的边缘分布,类似于历史图 . |
例子:'Kernel','overlay'
'Bandwidth'
—带宽of kernel smoothing window带宽of kernel smoothing window, specified as the comma-separated pair consisting of'Bandwidth'
and a matrix of size 2-by-K, 在哪里Kis the number of unique groups. The first row of the matrix gives the bandwidth of each group inx
,第二行给出了每个组的带宽y
. By default,scatterhist
finds the optimal bandwidth for estimating normal densities. Specifying a different bandwidth value changes the smoothing characteristics of the resulting kernel density plot. The value specified is a scaling factor for the normal distribution used to generate the kernel density plot.
例子:'Bandwidth',[.5,.2,.1;.15,.25,.35]
数据类型:single
|双倍的
'Legend'
—传奇可见性指标'on'
|'离开'
传奇可见性指标, specified as the comma-separated pair consisting of'Legend'
and one of the following.
'on' |
Set legend visible. This is the default if aGroup parameter is specified. |
'离开' |
设置传奇看不见。这是默认值Group parameter is not specified. |
例子:'Legend','on'
'linestyle'
—Style of kernel density plot lineStyle of kernel density plot line, specified as the comma-separated pair consisting of'linestyle'
and a valid line style or a string array or cell array of valid line styles. Seeplot
for valid line styles. The default is a solid line. Use a string array or cell array to specify different line styles for each group. When the total number of groups exceeds the number of specified values,scatterhist
cycles through the specified values.
例子:'linestyle',{'-',':','-.'}
数据类型:char
|细绳
|cell
'行宽'
—内核密度图线的宽度0.5
(默认)|nonnegative scalar value|vector内核密度图线的宽度,指定为逗号分隔对'行宽'
以及非负标量值的非负标量值或向量。指定的值是以点测量的内核密度图线的大小。默认大小为0.5点。使用向量为每个组指定不同的线宽度。当组总数大于指定值的数量时,scatterhist
cycles through the specified values.
例子:'行宽',[0.5,1,2]
数据类型:single
|双倍的
'颜色'
—Marker color for each scatter plot groupMarker color for each scatter plot group, specified as the comma-separated pair consisting of'颜色'
and a character vector or string scalar of color names, or a three-column matrix of RGB values in the range [0,1]. If you specify colors using a matrix, then each row of the matrix is an RGB triplet that represents a group. The three columns of the matrix represent the R value, G value, and B value, respectively. When the total number of groups exceeds the number of specified colors,scatterhist
cycles through the specified colors.
This table lists the predefined colors and their equivalent RGB triplet values.
Option | 描述 | 等效的RGB三胞胎 |
---|---|---|
'red' or'r' |
Red | [1 0 0] |
'green' or'G' |
绿色的 | [0 1 0] |
'蓝色的' or'b' |
Blue | [0 0 1] |
'黄色' or'y' |
Yellow | [1 1 0] |
'品红' or'M' |
Magenta | [1 0 1] |
'cyan' or'C' |
青色 | [0 1 1] |
'white' or'w' |
White | [1 1 1] |
'black' or'K' |
Black | [0 0 0] |
例子:'颜色','kcm'
例子:'颜色',[.5,0,1;0,.5,.5]
数据类型:single
|双倍的
|char
|细绳
'Marker'
—Marker symbol for each scatterplot group'o'
(默认)|角色向量|细绳scalarMarker symbol for each scatter plot group, specified as the comma-separated pair consisting of'Marker'
and a character vector or string scalar of one or more valid marker symbols. Seeplot
对于有效的符号。默认值为'o'
, a circle. When the total number of groups exceeds the number of specified symbols,scatterhist
循环通过指定的符号。
例子:“标记”,'+do'
数据类型:char
|细绳
'MarkerSize'
—Marker size for each scatter plot group6
(默认)|nonnegative scalar value|vector每个散点图组的标记大小,指定为逗号分隔对'MarkerSize'
以及非负标量值或非负标量值的向量,以点为点。当组总数超过指定值的数量时scatterhist
cycles through the specified values.
例子:'MarkerSize',10
数据类型:single
|双倍的
h
- 轴柄Axes handles for the three plots, returned as a vector. The vector contains the handles for the scatter plot, the histogram along the horizontal axis, and the histogram along the vertical axis, respectively.
Alternatively, you can create aScatterHistogramChart
对象通过使用分散组织图
function.
Explore the data interactively in the object by panning, zooming, and using data tips. Unlike thescatterhist
function,分散组织图
根据当前散点图限制中的数据更新边缘直方图。
Control the appearance and behavior of the scatter histogram chart by changing theScatterHistogramChart Properties.
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。金宝app
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:.
Selectweb siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.