本文介绍了在matlab的子图中分组散点图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用matlab中的grouped scatterhist函数进行子图绘制.

I am trying to make subplots using the grouped scatterhist function in matlab.

subplot(2,2,1)
scatterhist(x,y,'Group',factor)
subplot(2,2,2)
scatterhist(x,y,'Group',factor)

这将形成第二个子图的一个正常大小的图.有任何想法吗?

This makes one normal sized plot of the second subplot. Any ideas?

推荐答案

scatterhistsubplot互动不佳,因此您必须找到解决方法.

scatterhist doesn't interact well with subplot, so you have to find ways around that.

这是使用uipanel的一种方法.

% create two separate figures with the two scatterplots in
h1 = figure
scatterhist(x,y,'Group',factor)
h2 = figure
scatterhist(x,y,'Group',factor)

% create third figure split into two uipanels
h3 = figure
u1 = uipanel('position',[0,0,0.5,1]);
u2 = uipanel('position',[0.5,0,0.5,1);

% get all children from each figure and move to the uipanels
set(get(h1,'Children'),'parent',u1);
set(get(h2,'Children'),'parent',u2);

%close unneeded figures
close(h1,h2)

如果您想做很多这样的事情,您可能想创建一个函数,该函数根据图中需要多少个子图计算出正确的position值.

If you wanted to do a lot of these, you might want to create a function that works out the right position values depending on how many subplots you want in the figure.

这篇关于在matlab的子图中分组散点图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 16:33