【问题标题】:grouped scatterhist in subplot in matlabmatlab子图中的分组散点图
【发布时间】:2014-02-03 23:48:20
【问题描述】:

我正在尝试使用 matlab 中的 grouped scatterhist 函数制作子图。

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

这使得第二个子图的一个正常大小的图。有任何想法吗?

【问题讨论】:

    标签: matlab


    【解决方案1】:

    scatterhist 无法与subplot 很好地交互,所以你必须想办法解决这个问题。

    这是使用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 值,具体取决于您想要在图中多少子图。

    【讨论】:

      猜你喜欢
      • 2013-02-12
      • 2013-12-17
      • 1970-01-01
      • 2013-08-17
      • 1970-01-01
      • 2017-09-04
      • 1970-01-01
      • 2014-11-26
      • 2013-08-31
      相关资源
      最近更新 更多