[scilab-Users] Copying windows in subplot

Manuel JULIACHS manuel.juliachs at scilab.org
Fri Feb 19 16:36:25 CET 2010


Mathieu Dubois a écrit :
> Hello everybody,
>
> I have made a lot of plots in different windows and carefully saved 
> the handles in a list.
>
> For publication it's easier to have a single large figure with 
> subplots. Therefore I would like to copy each window inside a subplot 
> (because the data are long to process I would like to copy only the 
> plots not rerun the script).
>
> I have tried to use copy like in this simple example but it doesn't work:
> // Two simple plots on different windows
> x=-%pi:0.1:%pi;
> h1=scf(); plot(x, sin(x));
> h2=scf(); plot(x, cos(x));
>
> h=scf();
> // Copy h1 in the first subplot
> subplot(211);
> a=gca();
> copy(h1, a);
>
> // Copy h2 in the second subplot
> subplot(212);
> a=gca();
> copy(h2, a);
>
> Is there a graphic guru to enlighten us (me)?
>
> Thanks in advance,
> Mathieu
>

Hello,

there is an error in your example: the entity copied cannot be
a Figure object. Instead, you must copy the Axes objects attached to
the first two figures into the third one, using the latter's own Axes object
as a destination:


x=-%pi:0.1:%pi;

scf(); plot(x, sin(x)); h1=gca();
scf(); plot(x, cos(x)); h2=gca();


Furthermore, you can do without using subplot:

h=scf();
a=gca();
copy(h1,a);
copy(h2,a);

However, as h already owns an Axes object (created by default), it must 
be deleted,
as it is supernumerary:

delete(h.children(3));


Last, you must resize every copied Axes object by modifying the 
data_bounds property,
in order for them to fit on the figure:

h.children(2).axes_bounds=[0.0, 0.0, 1.0, 0.5];
h.children(1).axes_bounds=[0.0, 0.5, 1.0, 0.5];


the full example being:


x=-%pi:0.1:%pi;

scf(); plot(x, sin(x)); h1=gca();
scf(); plot(x, cos(x)); h2=gca();

h=scf();
a=gca();
copy(h1,a);
copy(h2,a);

delete(h.children(3));

h.children(2).axes_bounds=[0.0, 0.0, 1.0, 0.5];
h.children(1).axes_bounds=[0.0, 0.5, 1.0, 0.5];


Copying n Axes objects into a single figure essentially requires the 
same operations (n copy calls).
Be careful, though, to correctly recompute each copied object's 
axes_bounds property as a function of n
(check out the axes_properties help page for related information).

-- 
-------------------------
Manuel Juliachs
Ingénieur de développement
-------------------------
Consortium Scilab
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105 
78153 Le Chesnay Cedex France
Tél. : +33.1.39.63.52.71




More information about the users mailing list