help-octave
[Top][All Lists]
Advanced

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

Re: Subplot size


From: Francesco Potortì
Subject: Re: Subplot size
Date: Fri, 28 Feb 2020 11:38:21 +0100

Henk Borsje:
>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.

I suspect that not using get is not a minor difference, but the main
reason why you observe that behaviour.  I am not an expert in how plots
are built inside Octave, but graphs have scalable (axes, lines) and
nonscalable (fixed-size fonts, markers) elements, so enlarging a graph
is a complex operation under the cover, and setting positions that work
for all sizes is not easy.  To better clarify this, I have used
self-explaining variables names in my code below.  The result of that
code, in my environment on fltk, stays the same when you resize the
window to any size and proportions that I have tried:

m = 8;                                  # make m graphs
scale =  [1 1 1.2 2.5];                 # found by trial and error
offset = [-0.075 -0.05 0 0];            # found by trial and error
for i = 1:m
 ah = subplot(m,1,i);
 plot(rand(1,100))
 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') .* scale + offset;
 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



reply via email to

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