[scilab-Users] figures + handles

Antoine Monmayrant antoine.monmayrant at laas.fr
Mon Aug 23 12:46:58 CEST 2010


Le 23/08/2010 12:28, Carrico, Paul a écrit :
> Dear All
>
> In the following example, how can i :
> - have 2 polylines with 2 differnte color ?
> - add the legends ?
>
> All my attempts failed
>
> Thanks for any help
>
>
> Paul
>
> PS : the following (if it's added) failed
> e.children(1) = 1 // color of the 1rst line
> e.children(2) = 3 // color of the 2nd line
> legends(['TRACTION' 'DROITE'],opt=2)
>
>
>
> ########################################################################
>    drawlater();
>    xgrid(3);
>    f = gcf();
>    f.figure_size = [1000, 1000];
>    f.background = color(245,245,245);
>    a = gca();
>    a.font_size = 2;
>    a.x_label.text = "Epsilon " + string(type_deformation) + " [-]";
>    a.x_label.font_size = 4;
>    a.y_label.text = "Sigma [MPa]";
>    a.Y_label.font_size = 4;
>    if (choix_titre == 1) then
>     a.title.text = ("Resultat TRACTION sur " + string(nom_mat) + " +
> module d''Young");
>     a.title.font_size = 5;
>    end
>    a.line_style = 1;
>
>    plot(TRACTION_FIG(:,3),TRACTION_FIG(:,4),line_style=1)
>    plot(TRACTION_YOUNG(:,1),TRACTION_YOUNG(:,2),line_style=2)
>    e = gce()
>    e
>    p = e.children
>    p.thickness = 2 ;
>    p.line_style = 1;
>    drawnow();
>
>
>
>
>
>
>
>
> --------------------------------------------------------------------------------
>
>
> Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.
>
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.
>
>    
You can try the following code to see how to get what you want:

/////////////////////////////////////////////////////////////////////////////////////////////////////
x=[-10:0.1:10];
y1=sin(x);
y2=cos(x);

// this is your code
f = gcf();
   f.figure_size = [1000, 1000];
   f.background = color(245,245,245);
   a = gca();
   a.font_size = 2;
   a.x_label.text = "Epsilon " +"" + " [-]";
   a.x_label.font_size = 4;
   a.y_label.text = "Sigma [MPa]";
   a.Y_label.font_size = 4;

//

plot(x,y1)
e1=gce();    //handle to first polyline
plot(x,y2);
e2=gce();    //handle to second polyline
e1.children.foreground=color("orange");
e2.children.foreground=color("forest green");
legend("This is orange Cos", "This is green Sin");
/////////////////////////////////////////////////////////////////////////////////////////////////////

The key idea is that gce() returns the handle to the current element 
(the last one you plotted in this case).
So unless you want to browse all the children of the "f" handle to finde 
the handle your are looking for, the best is to call gce() after each 
plot to keep an handle for each element you plotted on the graph.

Cheers,

Antoine




More information about the users mailing list