From: esozo on 18 Jun 2010 19:41 Hi there, does someone know a solution to this problem you are sure about it REALLY WORKS... I need to create 10 subplots located 2 x 5, but there is too much space in between http://img257.imageshack.us/img257/4871/wrongf.png I tried to adjust the position of subplots. I don't kinda see to what values shall I reset position. Tried already a couple of things and this is the best wrong option (tiitles to subplots are suppressed) http://img85.imageshack.us/img85/3507/noeffect.png Here is code piece: subaxes = subplot(subplotrownum,subplotcolnum,subplotelemnum); p = get(subaxes, 'pos'); p(1) = p(1) + 0.02; p(2) = p(2) - 0.05; p(3) = p(3) + 0; p(4) = p(4) + 0; set(subaxes, 'pos', p); It's based on an idea I found back in a post that position 'd be a [left bottom width height] normalized vector, and 0.05 = 5 % of figure window. Well I don't know... http://www.mathworks.ch/matlabcentral/newsreader/view_thread/144116 Any good idea how to improve my code? Or give some totally other idea, but pls a verified one. Thanks!!
From: Matt Fig on 18 Jun 2010 20:12 Adjust as necessary: figure('units','pix',... 'pos',[400 400 900 600]) x = 0:.1:10; for ii = 1:6 S.ax(ii) = subplot(2,3,ii); plot(S.ax(ii),x,x.^ii); end set(S.ax,'units','pix'); P = get(S.ax,'pos'); pause(1) % Just to see what is going on. P = cellfun(@(x) x-[40 0 0 0],P,'Un',0); % Store new position for future use.... set(S.ax,{'pos'},P) pause(1) % Just to see what is going on. P = cellfun(@(x) x + [0 0 55 0],P,'Un',0); set(S.ax,{'pos'},P)
From: us on 18 Jun 2010 20:16 "esozo " <esozo001(a)aol.de> wrote in message <hvh06g$p1f$1(a)fred.mathworks.com>... > Hi there, > > does someone know a solution to this problem you are sure about it REALLY WORKS... I need to create 10 subplots located 2 x 5, but there is too much space in between > http://img257.imageshack.us/img257/4871/wrongf.png > > I tried to adjust the position of subplots. I don't kinda see to what values shall I reset position. Tried already a couple of things and this is the best wrong option (tiitles to subplots are suppressed) > http://img85.imageshack.us/img85/3507/noeffect.png > > Here is code piece: > > subaxes = subplot(subplotrownum,subplotcolnum,subplotelemnum); > p = get(subaxes, 'pos'); > p(1) = p(1) + 0.02; > p(2) = p(2) - 0.05; > p(3) = p(3) + 0; > p(4) = p(4) + 0; > set(subaxes, 'pos', p); > > It's based on an idea I found back in a post that position 'd be a [left bottom width height] normalized vector, and 0.05 = 5 % of figure window. Well I don't know... > http://www.mathworks.ch/matlabcentral/newsreader/view_thread/144116 > > Any good idea how to improve my code? Or give some totally other idea, but pls a verified one. Thanks!! one of the many solutions % the data % - #rows/cols... nr=3; nc=4; % - combined axis's height/width... roff=.1; rlen=.8; coff=.1; clen=.8; % the engine rl=rlen/nr; cl=clen/nc; rix=roff:rl:roff+rlen-rl; cix=coff:cl:coff+clen-cl; [xp,yp]=meshgrid(cix,rix); ah=nan(nr,nc); % the result ca=0; for ir=1:nr for ic=1:nc ca=ca+1; ah(ir,ic)=axes('position',[xp(ir,ic),yp(ir,ic),cl,rl]); text(.5,.5,sprintf('axis %3d',ca),'horizontalalignment','center'); end end set(ah,'xtick',[],'ytick',[]); % - on display... shg us
From: TideMan on 18 Jun 2010 22:26 On Jun 19, 11:41 am, "esozo " <esozo...(a)aol.de> wrote: > Hi there, > > does someone know a solution to this problem you are sure about it REALLY WORKS... I need to create 10 subplots located 2 x 5, but there is too much space in betweenhttp://img257.imageshack.us/img257/4871/wrongf.png > > I tried to adjust the position of subplots. I don't kinda see to what values shall I reset position. Tried already a couple of things and this is the best wrong option (tiitles to subplots are suppressed)http://img85.imageshack.us/img85/3507/noeffect.png > > Here is code piece: > > subaxes = subplot(subplotrownum,subplotcolnum,subplotelemnum); > p = get(subaxes, 'pos'); > p(1) = p(1) + 0.02; > p(2) = p(2) - 0.05; > p(3) = p(3) + 0; > p(4) = p(4) + 0; > set(subaxes, 'pos', p); > > It's based on an idea I found back in a post that position 'd be a [left bottom width height] normalized vector, and 0.05 = 5 % of figure window. Well I don't know...http://www.mathworks.ch/matlabcentral/newsreader/view_thread/144116 > > Any good idea how to improve my code? Or give some totally other idea, but pls a verified one. Thanks!! And here's yet another way of solving your problem: 1. Take a sheet of paper - graph paper would be good - and draw on it a plan of the panels you want. 2. Assuming that height of the sheet is 1 and width of the sheet is 1, write down the coordinates of the bottom left corner of each panel, and the panel's width and height. 3. In Matlab, for each panel, you will define it like this: axes('Position',[left bottom width height]) where left and bottom are the coordinates of the bottom left corner of the panel and width and height are panel's width and height; then you simply plot in that panel using: plot(t,y) If you do this manually the first time, you'll quickly figure out a way of doing it programmatically using two for loops: the outside one for the rows, and the inside one for the panels across the page.
From: esozo on 20 Jun 2010 09:41
Hi there, before I forget I would like to thank to every one for giving your time to rescue me. Starting from a blank sheet of paper as TideMan proposed :) in the end I wrote a few functions that worked somehow... a small example with random data... http://img163.imageshack.us/img163/1359/feedback1.png As first I createed a figure in centimeters, with one dimension as input, the other optimized depending on number and arrangement of subplots. Then I calculated inside dimensions in centimeters and converted in normalized units. I only used one loop. Searching in helpfile took the most time, even after I understood what I had to do. All of you wrote with the purpose to help and make me understand, but I doubt the same can be said about those who wrote the helpfile. Maybe they could switch jobs to something they like to do and are skilled at. I am really "happy" for each minute I waisted with this. P.S.: There remained question which I did not resolve, these two lines just ignored each other: set(gca, 'Units', 'centimeters'); thishandle = subplot('Position', [left bottom width height]); Does anyone know how to make them work? I did not use them in the end. |