help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subplot size


From: Brett Green
Subject: Re: Subplot size
Date: Thu, 20 Feb 2020 16:35:53 -0500


On Thu, Feb 20, 2020 at 4:28 PM Henk Borsje <address@hidden> wrote:

I would like to plot multiple subplots in a single figure.  Because of the large number of graphs I want to suppress all labels from the horizontal axis, except the bottom one, and reduce the space between the graphs.  According to the documentation the ‘position’ parameter in the subplot can be used to define location and size of each subplot.  

 

When the script executes, in debug mode, the first ‘subplot’ command draws the expected layout for the first plot. However, when the subsequent ‘plot’ command is executed the size of the plot is reduced and the intended layout is ignored.   Can someone please tell me how I can reduce the wasted space between plots?

 

I’m using Octave 5.2 on Windows 10

 

Thanks for any help.

 

m = 8;

d = rand(100,m);

rnge = 1:100;

figure (1)

for i = 1:m

               x = 0.05;

               y = 0.95 - i * 0.9/m;

               width = 0.9;

               height = 0.9/m;

               subplot(m,1,i,'position',[x,y,width,height]);

               plot(rnge,d(:,i))

               if i == m

                              axis("tic","label")

               else

                              axis("ticy","labely")

               endif

               grid,ylabel(sprintf('Series %d',i));

              

               if i == 1

                              title('My title')

               endif

endfor

 



I have done this before with 2 plots using code of the form

h1 = subplot(2,1,1);
hold on
plot(x1,y1)
h2 = subplot(2,1,2);
hold on
plot(x2,y2)
oldposition1 = get(h1,"position");
set(h1,"position",newposition1)
oldposition2 = get(h2,"position");
set(h2,"position",newposition2)

where newposition1 was obtained by dilating and shifting oldposition1, and so on. If I remember correctly, it was important that I waited until all plots were plotted to resize them.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]