grouped scatterhist in subplot in matlab

前端 未结 1 1790
梦谈多话
梦谈多话 2021-01-23 20:21

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)
scat         


        
相关标签:
1条回答
  • 2021-01-23 20:50

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

    Here is a way of doing it with 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)
    

    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.

    0 讨论(0)
提交回复
热议问题