【问题标题】:Matlab - Subplot of 7 by 5 Scatterplots? [duplicate]Matlab - 7乘5散点图的子图? [复制]
【发布时间】:2014-11-26 18:04:28
【问题描述】:

如何在 Matlab 中创建一个包含所有、点和两个直方图的 7 x 5 散点图的子图?

例如,如果您尝试此代码,您会发现它不起作用:

x = randn(1,1000); 
y = randn(1,1000); 
subplot(2,2,1); 
scatterhist(x,y)

我尝试了上一篇文章中的以下代码:

close all
h1 = figure
scatterhist(x,y)
h2 = figure
scatterhist(x,y)

h3 = figure
u1 = uipanel('position',[0,0,0.5,1]);
u2 = uipanel('position',[0.5,0,0.5,1]);

set(get(h1,'Children'),'parent',u1);
set(get(h2,'Children'),'parent',u2);

close(h1,h2)

...这是输出:

我刚刚运行了 KevinMc 代码,它看起来是这样的:

谢谢!

【问题讨论】:

  • 你的意思是你想要一个7倍于你在图片中显示的数字吗?你自己生成的吗?
  • 请澄清问题 - 你想要图片中生成的 3 个地块的 7x5 倍吗?
  • 正是,这正是我所需要的。具有 7x5 图的子图矩阵
  • 没有重复,这不是我要找的。​​span>
  • 你显示的最后一张图片有什么问题?只是它没有你想要的那么多面板吗?

标签: matlab scatter-plot subplot


【解决方案1】:

我没有 scatterhist,但这里有一些适用于 scatter 的东西

nCols = 7;
nRows = 5;

mainfig = figure;
for currRow = 1:nRows
    for currCol = 1:nCols
        h = figure;
        scatter(rand(100, 1), randn(100, 1));
        figure(mainfig);
        u(currRow, currCol) = uipanel('Position', [(currCol-1)/nCols, (currRow-1)/nRows, 1/nCols, 1/nRows]);
        set(get(h, 'Children'), 'parent', u(currRow, currCol));
        close(h);
    end
end

各个 uipanel 存储在句柄数组u 中。

【讨论】:

  • 嗨 KevinMc,非常感谢。这看起来像我需要的,但我仍然想包含直方图...... :(顺便说一句,我从你提供的代码中发布了这个数字
  • 只需在提供的代码中将 scatter 替换为 scatterhist 即可。正如我在答案中指出的那样,我没有包含 scatterhist 的包,所以我使用了 scatter。
猜你喜欢
  • 1970-01-01
  • 2013-08-17
  • 1970-01-01
  • 1970-01-01
  • 2013-02-12
  • 2013-12-17
  • 2013-08-31
  • 2015-08-27
  • 1970-01-01
相关资源
最近更新 更多