Orscilab
ORSCILAB
SCILAB 3.1 PAS-A-PAS
SCILAB 3.1 STEP-TO-STEP

Jacques-Deric Rouault

Laboratoire de Neurobiologie de l'Apprentissage, de la Mémoire et de la Communication. CNRS UMR 8620, Bat. 446, Université Paris-Sud, F91400 Orsay


Volume 4   LE GRAPHISME
Volume 4   GRAPHISM
4.31 LE HANDLE LEGEND
4.31 
THE HANDLE LEGEND

Version 3.1.100 du 29 juin 2005 / Version 3.1.100, June 29th 2005
Scilab 3.1.1

4.30       LE HANDLE AGREGATION / THE HANDLE AGREGATION
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.38       LE GRAPHISME 2D / THE 2D GRAPHISM

4.31.01   Présentation  / Presentation
4.31.02   Liste des champs  / Fields list
4.31.03   Parent et enfants  / Parent and children
4.31.04   Déclaration  / Declaring
4.31.10   visible
4.31.20   line_mode
4.31.21   foreground
4.31.22   mark_mode
4.31.50   legend (F1)
4.31.51   legend (F2)
4.31.52   legend (F3)
4.31.60   legends (P1)
4.31.61   legends (P2)
4.31.62   legends (P3)
4.31.98   Mon point de vue  / My viewpoint
4.31.99   Zones d'ombre  / Shadowy areas

4.31.01   Présentation  / Presentation

Legend

Le handle Legend permet d'inscrire une légende à coté d'une figure graphique.
The handle Legend allows to insert a legend near a graphic figure.

Le handle Legend est progressivement abandonné au profit d'un handle Agregation avec des enfants Polyline, Text et Rectangle.
The handle Legend is progressively left for a handle Agregation with children Polyline, Text and Rectangle.

Les procédures legend et legends traitées dans ce chapitre ne créent pas de handle Legend mais un handle Agregation.
The procedures legend and legends described in this chapter do not create a handle Legend but a handle Agregation.

4.31.02   Liste des champs  / Fields list

Le handle Legend contient 11 champs.
The handle Legend has 11 fields.

disp ("4.31.02A");
hf = scf (1);
x = [0,1,2,3,5];
y = [1, 5, 2 ,3, 1];
plot2d (x, y, strf="181", leg="courbe");
hg = gce (),
hd = hg.children(1),
delete (hf);



4.31.03   Parent et enfants  / Parent and children

Le handle legend a pour parent un handle de type Agregation
The handle label has for parent a handle Agregation.

Le handle legend n'a pas d'enfants
The handle label has no children.

4.31.04   Déclaration  / Declaring

La déclaration d'un handle Legend est implicite : on lance la procédure plot2d avec l'option strf avec le premier caractère a=1 et l'option leg, on récupère le handle Agregation et le premier handle enfant Legend.
The declaration of a handle Legend is implicit: first run the procedure plot2d with otion strf with a first character a=1, and option leg, then recover the handle Agregation and its first children Legend.

disp ("4.31.04A");
hf = scf (1);
x = [0,1,2,3,5];
y = [1, 5, 2 ,3, 1];
plot2d (x, y, strf="181", leg="Courbe");
hg = gce ();
hd = hg.children(1),
delete (hf);



4.31.10   visible

visible (Legend)
@ (Legend)

Le champ visible du handle Legend controle si la figure qu'il contient est représenté (valeur "on") ou n'est pas représenté (valeur "off"). La valeur par défaut est la valeur de axes.visible, en général "on".
The field visible of the handle Label controls if the figure it contains is represented (value "on") or is not represented (value "off"). The default value is the value of  axes.visible, usually "on".

disp ("4.31.10A");
hf = scf (1);
hf.figure_name = "4.31.10A1";
x = [0,1,2,3,5];
y = [1, 5, 2 ,3, 1];
plot2d (x, y, strf="181", leg="courbe");
hg = gce ();
hd = hg.children(1),
xpause (5000000);

hf.figure_name = "4.31.10A2";
hd.visible = "off";
xpause (5000000);

hf.figure_name = "4.31.10A3";
hd.visible = "on";
xpause (5000000);
delete (hf);

La premiere légende courbe est affichée sous l'axes des x entre 0.0 et 0.5, puis le champ visible passe à off et la légende n'est pas affichée, puis champ visible passe à on et la légende est à nouveau affichée.
The first legend courbe is displayed under the x axis between 0.0 and 0.5, then the field visible becomes off and the legend is not displayed, then the field visible becomes on and the legend is displayed again .



Quand plusieurs courbes sont tracées, les différentes légendes sont placées dans une seule chaine et sont séparées par @. Les couleurs du tracé comme de la légende sont prises dans l'ordre dans la palette courante.
When several curves are drawn, the different legends are put in a single string  and are separated by @. The colors of the drawings and of the legends are taken in order in the current palette.

disp ("4.31.10B");
hf = scf (1);
hf.figure_name = "4.31.10B";
x = [0,1,2,3,5];
y = [1,2,3; 3,5,1; 2,3,4; 0,0,0; 1,2,3];
plot2d (x, y, strf="181", leg=["Courbe 1@Courbe 2@Courbe 3"]);
hg = gce ();
hd = hg.children(1),
xpause (5000000);
delete (hf);



4.31.20   line_mode

line_mode (Legend)

Le champ line_mode du handle Legend controle si la ligne tracée est représenté (valeur "on") ou n'est pas représenté (valeur "off"). La valeur par défaut est "off".
The field line_mode of the handle Legend controls if the line drawn is represented (value "on") or is not represented (value "off"). The default value is "off".

disp ("4.31.20A");
hf = scf (1);
hf.figure_name = "4.31.20A1";
x = [0,1,2,3,5];
y = [1,2,3; 3,5,1; 2,3,4; 0,0,0; 1,2,3];
plot2d (x, y, strf="181", leg=["Courbe 1@Courbe 2@Courbe 3"]);
hg = gce ();
hd = hg.children(1),
xpause (5000000);

hf.figure_name = "4.31.20A2";
hd.line_mode = "on";
xpause (5000000);

hf.figure_name = "4.31.20A3";
hd.line_mode = "off";
xpause (5000000);
delete (hf);



NB : La ligne est représentée, que le champ line_mode ait la valeur "on" ou "off". (BUG ?)
NOTE: The line is displayed when the field line_mode has the value "on" or "off" (BUG ?)

4.31.21   foreground

foreground (Legend)

Le champ foreground du handle Légend définit la couleur du tracé de la ligne. Cette couleur est codée par une valeur entière, dans la limite des valeurs définies par le champ figure.color_map (32 par défaut). La valeur par défaut est axes.foreground, en principe -1 (noir) .
The field foreground of the handle Legend defines the color of the drawing of the line. This color is coded as an integer value, in the limits of the values defined by the field figure.color_map (by default 32). The default value is axes.foreground, usually -1 (black).

disp ("4.31.21A");
hf = scf (1);
hf.figure_name = "4.31.21A1";
x = [0,1,2,3,5];
y = [1,2,3; 3,5,1; 2,3,4; 0,0,0; 1,2,3];
plot2d (x, y, strf="181", leg=["Courbe 1@Courbe 2@Courbe 3"]);
hg = gce ();
hd = hg.children(1),
hd.foreground = 5;
xpause (5000000);
delete (hf);



NB : La couleur Legend.foreground s'applique au texte mais pas à la ligne. (BUG ?)
NOTE: The color Legend.foreground is applied to the text but not to the line (BUG ?)

4.31.22   mark_mode

mark_mode (Legend)

Le champ mark_mode du handle Legend définit si les marques sont affichées (valeur "on"), ou ne seront pas affichées (valeur "off"). La valeur par défaut est  axes.mark_mode, en principe "off".
The field mark_mode of the handle Legend defines if the marks are displayed (value "on") or are not displayed (value "off"). The default value is axes.mark_mode, usually "off".

disp ("4.31.22A");
hf = scf (1);
hf.figure_name = "4.31.22A1";
x = [0,1,2,3,5];
y = [1,2,3; 3,5,1; 2,3,4; 0,0,0; 1,2,3];
plot2d (x, y, strf="181", style=[-1,2,-3],  leg=["Courbe 1@Courbe 2@Courbe 3"]);
hg = gce ();
hd = hg.children(1);
hd.mark_mode = "on",
xpause (5000000);

hf.figure_name = "4.31.22A2";
hd.mark_mode = "off",
xpause (5000000);

hf.figure_name = "4.31.22A3";
hd.mark_mode = "on",
xpause (5000000);
delete (hf);



NB : Le champ mark_mode n'a pas d'incidence sur le tracé. (BUG ?)
NOTE: The field mark_mode has no incidence on the drawing (BUG ?)

4.31.50   legend (F1)

legend (P1)

La fonction legend dessine une légende et construit un handle Agregation avec des enfants Polyline, Text et Rectangle. Cette fonction est toatalement indépendante des tracés effectués avec plot2d et ne générère pas de handle Legend.
The function legend draws a legend and builds a handle Agregation with children Polyline, Text and Rectangle. This function is totally independent from drawings performed with plot2d and does not generate any handle Legend.

Les textes des légendes peut être donné sous la forme d'une liste de chaines ou d'un vecteur de chaines.
The texts of the legends can be defined under the form of a list of text of strings or of a vector of strings.

disp ("4.31.50A");
hf = scf (1);
hf.figure_name = "4.31.50A";
hg = legend ("Courbe 1", "Courbe 2", "Courbe 3"),
xpause (5000000);
delete (hf);





disp ("4.31.50B");
hf = scf (1);
hf.figure_name = "4.31.50B";
hg = legend (["Courbe 1", "Courbe 2", "Courbe 3"]),
xpause (5000000);
delete (hf);

disp ("4.31.50C");
hf = scf (1);
hf.figure_name = "4.31.50C";
hg = legend (["Courbe 1"; "Courbe 2"; "Courbe 3"]),
xpause (5000000);
delete (hf);

La légende se réfère implicitement aux handles Polylines enfant du handle Axes.
The legends implicitly refer to handles Polyline children of handle Axes.

disp ("4.31.50D");
hf = scf (1);
hf.figure_name = "4.31.50D";
ha = hf.children;
ha.axes_visible = "on";
ha.box = "on";
x = [0.1, 0.1; 0.3,0.3; 0.5,0.5; 0.7,0.7; 0.9,0.9];
y = [0.1, 0.9; 0.9,0.1; 0.5,0.3; 0.9,0.1; 0.1,0.5];
xpolys (x, y);
hg = gce (),
hp1 = hg.children (1),
hp1.foreground = 5;
hp1.mark_mode = "on";
hp1.mark_style = 3;
hp1.mark_size = 3;
hp1.mark_foreground = 5;
hp1.mark_background = 6;
hp2 = hg.children (2),
hp2.foreground = 3;
hp2.thickness = 5;
hh = legend ("Courbe 1", "Courbe 2");
xpause (5000000);
delete (hf);



4.31.51   legend (F2)

legend (P2)

Dans la fonction legend de seconde forme, on indique en plus l'endroit où sera positionné la légende (par défaut le coin supérieur droit de la fenetre graphique), et/ou si le cadre rectangle est tracé (booléen %T=Oui par défaut).
In the function legend of the second form, the place where is located the legend (by default the upper right corner of the graphic window) and/or if the rectangle frame is drawn (boolean %T=Yes by default).

L'emplacement de la légende peut être désigné sous deux formes : un entier à valeurs dans 1..5 ou un vecteur de deux flottants.
The place of the legend can be defined under two forms:an integer with values in 1..5 or a 2-float vector.

La valeur1 de l'entier indique le coin supérieur droit (valeur par défaut), 2 le coin supérieur gauche, 3 le coin inférieur gauche, 4 le coin inférieur droit et 5 un déplacement interactif avec la souris.
The integer value 1 designs the upper right corner (default value), 2 the upper left corner, 3 the lower left corner, 4 the lower right corner and 5 an interactive moving with the mouse.
.
disp ("4.31.51A");
hf = scf (1);
hf.figure_name = "4.31.51A";
hg = legend ("Courbe 1", "Courbe 2", "Courbe 3", 2, %F);
xpause (5000000);
delete (hf);



disp ("4.31.51B");
hf = scf (1);
hf.figure_name = "4.31.51B";
hg = legend ("Courbe 1", "Courbe 2", "Courbe 3", 5, %T);
xpause (5000000);
delete (hf);

Déplacer le rectangle avec la souris et cliquer pour fixer sa place.

Move the rectangle with the mouse, then click to fix its place.



L'emplacement indiqué sous forme vectorielle correspond aux coordonnées du coin supérieur gauche du cadre rectangulaire de la légende

The location designed under the vectorial form corresponds to the coordinates of the upper left corner of the rectangle box of the legend.

disp ("4.31.51C");
hf = scf (1);
hf.figure_name = "4.31.51C";
ha = hf.children;
ha.axes_visible = "on";
ha.box = "on";
ha.grid = [3, 4];
hg = legend ("Courbe 1", "Courbe 2", "Courbe 3", [0.0,1.0], %T);
xpause (5000000);
delete (hf);



4.31.52   legend (F3)

legend (P3)

Dans la fonction legend de troisième forme, on indique en plus dans un vecteur les handles Polyline auxquelles la légende se réfère.
In the function legend of the third form, the vector with handles Polyline which the legend corresponds  is provided.
.
disp ("4.31.52A");
hf = scf (1);
hf.figure_name = "4.31.52A";
ha = hf.children;
ha.axes_visible = "on";
ha.box = "on";
x = [0.1, 0.1; 0.3,0.3; 0.5,0.5; 0.7,0.7; 0.9,0.9];
y = [0.1, 0.9; 0.9,0.1; 0.5,0.3; 0.9,0.1; 0.1,0.9];
xpolys (x, y);
hg = gce (),
hp1 = hg.children (1),
hp1.foreground = 5;
hp1.mark_mode = "on";
hp1.mark_style = 3;
hp1.mark_size = 3;
hp1.mark_foreground = 5;
hp1.mark_background = 6;
hp2 = hg.children (2),
hp2.foreground = 3;
hp2.thickness = 5;
hh = legend ([hp1,hp2], "Courbe 1", "Courbe 2", 2, %T);
xpause (5000000);
delete (hf);





4.31.60   legends (P1)

legends (P1)

La procedure legends dessine une légende à partir de textes et de styles et construit un handle Agregation avec des enfants Polyline, Text et Rectangle. Cette fonction est totatalement indépendante des tracés effectués avec plot2d et ne génerère pas de handle Legend.
The procedure legends draws a legend from texts and styles and builds a handle Agregation with children Polyline, Text and Rectangle. This function is totally independent from drawings performed with plot2d and does not generate any handle Legend.

Les textes des légendes peut être donné sous la forme d'un vecteur de chaines. Le style correspond à l'option style (voir le chapitre 4.39.50)
The texts of the legends can be defined under the form of a vector of strings. The style corresponds to the option style (see chapter 4.39.50).

disp ("4.31.60A");
hf = scf (1);
hf.figure_name = "4.31.60A";
legends (["Courbe 1", "Courbe 2", "Courbe 3"], [2, -3, 5]);
hg = gce (),
xpause (5000000);
delete (hf);



Déplacer la souris et cliquer pour positionner la légende.

Move the mouse and click to locate the legend.



4.31.61   legends (P2)

legends (P2)

Dans la fonction legends de seconde forme, on indique en plus l'endroit où sera positionné la légende.
In the function legends of the second form, the place where is located the legend.

L'emplacement indiqué sous forme vectorielle correspond aux coordonnées du coin supérieur gauche du cadre rectangulaire de la légende
The location designed under the vectorial form corresponds to the coordinates of the upper left corner of the rectangle box of the legend.

disp ("4.31.61A");
hf = scf (1);
hf.figure_name = "4.31.61A";
ha = hf.children;
ha.axes_visible = "on";
ha.box = "on";
ha.grid = [3, 4];
legends (["Courbe 1", "Courbe 2", "Courbe 3"], [2, -3, 5], [0.0,1.0]);
xpause (5000000);
delete (hf);



4.31.62   legends (P3)

legends (P3)

Dans la fonction legends de troisième forme, on indique le coin où sera positionné la légende.
In the function legends of the third form, the corner where is located the legend is provided.

La valeur1 de l'entier indique le coin supérieur droit (valeur par défaut), 2 le coin supérieur gauche, 3 le coin inférieur gauche, 4 le coin inférieur droit et 5 un déplacement interactif avec la souris (par défaut).
The integer value 1 designs the upper right corner (default value), 2 the upper left corner, 3 the lower left corner, 4 the lower right corner and 5 an interactive moving with the mouse (default value).
.
disp ("4.31.62A");
hf = scf (1);
hf.figure_name = "4.31.62A";
legends (["Courbe 1", "Courbe 2", "Courbe 3"], [2, -3, 5], 1);
xpause (5000000);
delete (hf);



4.31.98   Mon point de vue  / My viewpoint

Le handle Legend va être rapidement considéré comme obsolete, car  progressivement abandonné au profit d'un handle Agregation avec des enfants Polyline, Text et Rectangle.
The handle Legend will rapidly be considered as obsolete, because progressively left for a handle Agregation with children Polyline, Text and Rectangle.

La logique initiale du style de ligne avec couleur ou marque contraint trop fortement les représentations graphiques. Il est clair que le handle Legend sera abandonné ou devra être fortement remanié.
The initial logic of the style of line with color or mark too strongly constraints the graphic representations. It is clear that the handle Legend will be give up or strongly recast.

Le handle Legend est très limité, et la fonction legend et la procédure legends construisent un handle Agregation et non un handle Legend.
The handle Legend is very limited,and the function legend and the procedure legends build a handle Agregation and not a handle Legend.

La meilleurs façon de construire une légende est de renoncer à l'automatisme ligne-légende et construire séparément un handle Agregation qui gère la légende. Reste le problème de la légende qui reste horizontale quand on tourne la figure.
The best way to build a legend is to give up to the automatism line-legend and to separately build a handle Agregation managing the legend. Remains the problem of the legend which remains horizontal when the figure rotates.

4.31.99   Zones d'ombre  / Shadowy areas

Le champ line_mode du handle Legend controle si la ligne tracée est représenté (valeur "on") ou n'est pas représenté (valeur "off"). La valeur par défaut est "off".
The field line_mode of the handle Legend controls if the line drawn is represented (value "on") or is not represented (value "off"). The default value is "off".

NB : La ligne est représentée, que le champ line_mode ait la valeur "on" ou "off".
NOTE: The line is displayed when the field line_mode has the value "on" or "off"

NB : La couleur Legend.foreground s'applique au texte mais pas à la ligne.
NOTE: The color Legend.foreground is applied to the text but not to the line .

NB : Le champ mark_mode n'a pas d'incidence sur le tracé. (BUG ?)
NOTE: The field mark_mode has no incidence on the drawing (BUG ?)

Dans l'ensemble, les valeurs des champs du handle Legend n'ont pas d'action sur la représentation.
Globally, the values of the fields of handle Legend have no action on the representation.

4.30       LE HANDLE AGREGATION / THE HANDLE AGREGATION
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.38       LE GRAPHISME 2D / THE 2D GRAPHISM