[英]How to overlay a stem plot over a box plot in MATLAB?
I have a vector 我有一个向量
A=[1 2 3 3 3 4 5]
I am able to show its box plot with 我能够显示它的箱形图
boxplot(A, 'orientation', 'horizontal')
I can also show its distribution with a stem plot like this 我也可以用这样的词干图来显示其分布
[nelements, centers] = hist(A);
stem(centers, nelements/numel(A), 'blue');
My question is how to combine these two plots into one figure? 我的问题是如何将这两幅图合并为一个图? The figure should have its y-axis
as probability and x-axis
as the A
values. 该图的y-axis
为概率, x-axis
为A
值。
As for the height of the box plot in the figure, it does not matter. 至于图中箱形图的高度,没关系。
How may I do this? 我该怎么办?
Use hold on
as follows, and be aware that you need to vertically move (using 'position'
again) your boxplot
to fit the axes of stem
请按以下方式使用hold on
,并注意您需要垂直移动(再次使用'position'
) boxplot
以适合stem
的轴
boxplot(A, 'orientation', 'horizontal','position',0.1); hold on
[nelements, centers] = hist(A);
stem(centers, nelements/numel(A), 'blue'); hold off
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.