如何使用“抓住”plotmatrix吗?
21日视图(30天)
显示旧的评论
我目前试图运行多个模拟和重叠的所有情节的抽样概率密度函数模拟在一个另一个在同一图通过“抓住”。For the histogram function this seems to work if I am plotting one variable, but if I am plotting multiple variables to show the marginal and joint distributions I would want to use plotmatrix. However, it looks like plotmatrix and "hold on" are not exactly compatible and don't produce the same result as using "hold on" with histogram.
我的代码的格式,这样做看起来大约像这种普遍性(简体):
n = 1;
而n < = 5
样品= my_function(参数);
图(1)
直方图(样本)
持有在
结束
我想做的是:
plotmatrix(样本)
持有在
而不是使用直方图来当我想把多个变量。但我试着使用plotmatrix只是一个变量思想,将直方图和做同样的事情并不——故事情节不叠加,而不是取代。
什么是适当的方式来达到我想要做什么?
接受的答案
戴夫B
2021年8月20日
编辑:戴夫B
2021年8月20日
plotmatrix,因为它使用多个轴,根本不适合与坚持…当你发现。
我能想到的三个解决方案:金宝搏官方网站
- 的gplotmatrix统计和机器学习的工具箱函数是面向plotmatrix与多个组。这需要一点重组你的数据(即把所有的设置为一个矩阵,和标签是哪个哪个分组变量)。这可能是最简单的方法(如果你有工具箱)
- 来虚度光阴,国际海事组织有点丑陋的一面,是让第二个plotmatrix图,然后将元素移动到一个新的旧图。几个额外的步骤来调整的限制和不同的颜色。(下面的例子有两个数据集)
- 我想如果是我,我会想写自己的装备mini-plotmatrix代码来处理这些数据……但这是稍微复杂一些。真的plotmatrix只是一群散射和直方图,它是很久以前写的tiledlayout和nexttile介绍了使布局工作变得容易得多。但是写一个简单的图表是一个事业!
x1 = abs (randn (1000 4));
x2 = abs (randn (1000 4));
[a, b, c, d, e) = plotmatrix (x1);
ftemp =图(“可见”,“关闭”);
[a2、b2, c2, d2, e2) = plotmatrix (x2);
为i = 1:元素个数(a2)
a2 (i) .Parent = b(我);
a2(我).SeriesIndex = 2;
%的联盟限制:
xlim (b) (i), [min ((b) (i) .XLim (1) b2 (i) .XLim(1)])马克斯((b) (i) .XLim (2) b2 (i) .XLim (2)))))
ylim (b) (i), [min ((b) (i) .YLim (1) b2 (i) .YLim(1)])马克斯((b) (i) .YLim (2) b2 (i) .YLim (2)))))
结束
为i = 1:元素个数(d2)
d2(我).Parent = e(我);
d2(我).SeriesIndex = 2;
xlim (e(我),(min ([e (i) .XLim (1) e2 (i) .XLim(1)])马克斯([e (i) .XLim (2) e2 (i) .XLim (2)))))
ylim (e(我),(min ([e (i) .YLim (1) e2 (i) .YLim(1)])马克斯([e (i) .YLim (2) e2 (i) .YLim (2)))))
结束
关上(ftemp)