[Scilab-users] Graphics: Current figure and current entity
Samuel Gougeon
sgougeon at free.fr
Tue Jun 7 21:06:31 CEST 2022
Le 07/06/2022 à 11:39, CRETE Denis a écrit :
>
> Hello,
>
> I have several graphic windows and in some of them, there are several
> “Axes” (and several curves for each “Axes”).
>
> I can’t find in “Scilab Help” if the “current axes” is always in the
> hierarchy of the “current entity”, and similarly if the “current
> figure” is always in the hierarchy of the “current axes”.
>
Good question. Let's test it :
1. sca(ax) sets the current figure to the one homing the ax axes:
--> scf(0); plot(1:10); e0 = gce(); ax0 = gca();
--> scf(1); plot(1:10); e1 = gce(); ax1 = gca();
--> sca(ax0);
--> gcf().figure_id
ans =
0.
--> sca(ax1);
--> gcf().figure_id
ans =
1.
2. set("current_entity", h) does NOT set the current figure to the one
homing the targeted entity:
--> scf(0); plot(1:10); e0 = gce(); ax0 = gca();
--> scf(1); plot(1:10); e1 = gce(); ax1 = gca();
--> set("current_entity", e0);
--> gcf().figure_id
ans =
1.
--> gca().parent.figure_id
ans =
1.
So now we can answer to your questions:
> I can’t find in “Scilab Help” if the “current axes” is always in the
> hierarchy of the “current entity”,
Almost never.
> and similarly if the “current figure” is always in the hierarchy of
> the “current axes”.
Yes it is.
> If this was true, I suggest to mention it in the “Graphics Entities”
> section.
>
Right, the sca() and set() pages could be clarified about this.
> If not, is there a simple way to obtain the handle of the figure where
> the “current entity” is ?
> I tried the following, which seems to work :
>
> G_f = gce().parent;
>
> while get(G_f,”type”)~=”Figure”,
>
> G_f = G_f.parent;
>
> end;
>
Yes, in short:
G_f = gce();
while G_f.type ~= ”Figure”, G_f = G_f.parent; end
that will work even when the initial G_f is already a figure.
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20220607/34a22278/attachment.htm>
More information about the users
mailing list