piermorel / gramm

Gramm is a complete data visualization toolbox for Matlab. It provides an easy to use and high-level interface to produce publication-quality plots of complex data with varied statistical visualizations. Gramm is inspired by R's ggplot2 library.
MIT License
784 stars 222 forks source link

adding a layout, such that I can make a multiplot which is in line with my metrology layout #115

Closed lmulder1991 closed 10 months ago

lmulder1991 commented 3 years ago

image

Is the Gramm toolbox capable to make a plot like this? So that I can make a multiplot which is corresponds to the locations where I measured. Would be nice if I could make a plot per measurement location and Ideally I would combine that with a %call g(1,1).stat_ellipse('type','95percentile','geom','area','patch_opts',{'FaceAlpha',0.1,'LineWidth',2}); Currently it puts all measurement together, but I'd like to have a ellipse at each location, indicating the variance of each location.

The closest that I could get to this is to make a loop: layout = [X1,X2,..Xn;Y1,Y2,...,Yn] t_temp.layout_id = [repmat(1:m,n)] dy = 0.1;% Height of plot dx = dy;% width of plot for i_pos = 1:size(layout,1) g(i_pos,1) = gramm('x',t_temp.x,'y',t_temp.y,'color',t_temp.channel,'group',t_temp.layout_id) g(i_pos,1).stat_ellipse('type','95percentile','geom','area','patch_opts',{'FaceAlpha',0.1,'LineWidth',2}); g(i_pos,1).set_layout_options('Position',[layout(_pos,1)-dx/2 layout(i_pos,2)-dy/2 dx dy],... %Set the position in the figure 'legend',false,... % No need to display legend for side histograms 'margin_height',[0.02 0.05],... %We set custom margins 'margin_width',[0.1 0.02],... 'redraw',false); %We deactivate automatic redrawing/resizing end

but maybe you already know a better way to make such a plot.

piermorel commented 10 months ago

Hi @lmulder1991 Always happy to see neuroscience data plotted with gramm. Indeed here you are proposing advanced customization, and I think the way you tried to do it with gramm is probably the best way. If your subplots could be rearranged or at least organized in a grid maybe it could be nice to use facet_grid() so that you get automatic scales etc. Then you would use g.facet_axes_handles' to retrieve the handles and make the empty ones invisible and possibly move the plotted ones. You would need to deactivate any redrawing by callingg.draw(false)`