[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Subplot size
From: |
Henk Borsje |
Subject: |
RE: Subplot size |
Date: |
Thu, 27 Feb 2020 11:29:13 +0100 |
I implemented your script more or less as you gave it, thank you. Only minor
difference is that I don't use a call to 'get' to find the plot position, only
a call to 'set'. But when I resize the figure during or after execution of the
script some of the subplots start dropping out. The same thing happens when I
change my default figure size before running the script. I've filed that as a
bug.
Here is the sample code I use:
m = 8;
rnge = 0.5:9.5;
figure (1)
pos = [ 0.07, 0, 0.92, 0.5/m];
for k = 1:4
d = rand(10,m);
%clf;
for i = 1:m
pos(2) = 0.95 - i * 0.91/m;
h = subplot(m,1,i);
plot(rnge,d(:,i))
set (h,'position',pos);
if i == m
axis("label")
else
axis("labely")
endif
grid,ylabel(sprintf('Series %d',i));
if i == 1
title('My title')
endif
endfor
pause(2)
endfor
-----Original Message-----
From: Francesco Potortì <address@hidden>
Sent: Friday, February 21, 2020 10:28 AM
To: Henk Borsje <address@hidden>
Cc: address@hidden
Subject: Re: Subplot size
>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.
By trial and error I managed to get to this (works on Octave 5.2.0 on Linux
with fltk):
m = 8;
d = rand(100,m);
rnge = 1:100;
figure (1), clf
for i = 1:m
ah = subplot(m,1,i);
plot(rnge,d(:,i))
if i == 1 title('My title') endif
grid,ylabel(sprintf('Series %d',i));
if i == m axis("tic","label") else axis("ticy","labely") endif pos =
get(ah,'position') .* [1 1 1.2 2.5] + [-0.075 -0.05 0 0]; set(ah, 'position',
pos); endfor
--
Francesco Potortì (ricercatore) Voice: +39.050.621.3058
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Skype: wnlabisti
(gate 20, 1st floor, room C71) Web: http://fly.isti.cnr.it