clc
x = [1:1:10];
y1 = x;
y2 = 2*x;
y3 = 3*x;
plot2d(x,y1);
plot2d(x,y2);
plot2d(x,y3)
gca().children(1).children(1).thickness = 2
gca().children(2).children(1).thickness = 7
gca().children(3).children(1).thickness = 4
I am new from Matlab to Scilab
Could someone tell me, how to unterstand children?
What means
gca().children
?
gca().children.children
?
gca().children.children(1)
?
gca().children(1).children
?
How can we know which attribute belong to children ?
e.g gca().children(1).children(1).color = ... // not exist
I am very confused now.. Thanks in Advance
Let's schematize the nested graphical object by their children properties.
We have
figure (f)
- axes (a)
- compound1 (c1)
- polyline (p1)
- compound2 (c2)
- polyline (p2)
- compound3 (c3)
- polyline (p3)
Since gca is a function lets do a = gca()
because gca().children
will raise an error because scilab doesn't understand that you're trying to access to the fields of its return value.
gca()
returns the handles to the axes of the current figure :a
.a.children
returns the array of handles of all the children of theses axes. : c1, c2, c3
a.children.children
returns the array of handles of all the children of the above objects: p1, p2, p3
a.children.children(1)
returns the first children of c1, c2, c3
: p1
a.children(1).children
returns all the children of the first children of the current axes (c1). Since there only one : p1
To access the value of your entities
Either go for a temp variable :
a = gca();
idcolor=a.children(1).children(1).foreground // gives the color of a.c1.p1
or use get
// idcolor is an array , with idcolor(i) the color of pi
idcolor = get(get(get(gca(),'children'),'children'),'foreground')
gce()
command returns the handle of the last object created. With plot2d its a compound so we need to get its children.
you could rewrite your program as
clc
x = [1:1:10];
y1 = x;
y2 = 2*x;
y3 = 3*x;
plot2d(x,y1);
e1 = get(gce(),'children');
plot2d(x,y2);
e2 = get(gce(),'children');
plot2d(x,y3)
e3 = get(gce(),'children');
e1.thickness = 2
e2.thickness = 7
e3.thickness = 4