
From:  Matthias Brennwald 
Subject:  Re: Lining up the axes of multiplots/subplots 
Date:  Fri, 17 Nov 2006 17:02:07 +0100 
The following works for me:  x1 = [1:0.1:10]; x2 = [3:0.1:15]; y1 = sin(x1); y2 = cos(x2); xLow = floor(min([x1 x2])); xHigh = ceil(max([x1 x2])); subplot(2,1,1); plot(x1,y1); axis([xLow xHigh min(y1) max(y1)]); subplot(2,1,2) plot(x2,y2); axis([xLow xHigh min(y2) max(y2)]); However, if the labels on the y axes are not of the same width, gnuplot may decide to move the position of the y axes, which will spoil the alignment of the two plots. If so, you will have to resort to using __gnuplot_raw__ . The following example illustrates this:
 x1 = [1:0.1:10]; x2 = [3:0.1:15]; y1 = sin(x1); y2 = 100000*cos(x2); xLow = floor(min([x1 x2])); xHigh = ceil(max([x1 x2])); subplot(2,1,1); plot(x1,y1); __gnuplot_raw__("set lmargin 10; \n") axis([xLow xHigh min(y1) max(y1)]); subplot(2,1,2) plot(x2,y2); __gnuplot_raw__("set lmargin 10; \n") axis([xLow xHigh min(y2) max(y2)]);  HTH, Matthias On 17.11.2006, at 14:36, address@hidden wrote:
Message: 7 Date: Fri, 17 Nov 2006 14:35:05 +0100 From: Joseph Wakeling <address@hidden> Subject: Lining up the axes of multiplots/subplots To: address@hidden MessageID: <address@hidden> ContentType: text/plain; charset=UTF8 Hello,I'm hoping someone can give me some advice on multiplot(), subplot() andrelated commands. I've played around with them a bit but not had success in achieving what I want. Here's the aim: two plots, one above the other, sharing the same X scale. The X axes must line up together. I want to plot several data sets in the first plot, and some different ones in the second. Now, I can do ... #first subplot(2,1,1) plot(x1,y1) hold on plot(x2,y2) #etc hold off #then subplot(2,1,2) plot(a1,b1) hold on plot(a2,b2) #etc hold off ... to get the plots one above the other, but this doesn't do anything to align the axes. What commands do I have to use to achieve this? Two related issues would be (a) the same, but sidebyside and sharing the same Y scale, and (b) overplotted graphs, where e.g. the X scale isthe same but there are two different Y scales on the left and right Y axes.Can anyone advise? Many thanks,  Joe
[Prev in Thread]  Current Thread  [Next in Thread] 