Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - English


set

set properties of some graphic objects or uimenus or uicontrol interactive components

Syntax

set(h, prop,val)            // h(prop) = val,  h.prop = val
set(h, prop,val, prop2,val2, ..)
set(tagsPath, prop,val)
set(tagsPath, prop,val, prop2,val2, ..)

set('current_figure', fig)  // scf(fig)
set('current_axes', axes)   // sca(axes)
set('current_entity', h)

Arguments

h
Handle of the graphic entity whose properti(es) must be set. h can be a vector of handles. In this case, set(..) modifies the property for all h components.

tagsPath
Case-sensitive character string providing the tag or the tags-path leading to the graphic component to process. This path is made of the strings recorded in the .Tag property of the parent figure and of the chain of its children down to the target, like "figuretag" to target the figure with figure.tag=="figuretag", or "figuretag/entitytag" to target one of its children (as for an axes, a main uimenu item, a block of legends,..), or "figuretag/entity1tag/entity2tag", etc. Wildcards can also be used for multi-paths search.

prop, prop2, ...
Scalar characters strings: Case-insensitive name of the properties to set.

val, val2, ...
value to assign to the property. Its type depends on the considered property. If h and val are vectors or matrices of same size, the multiple settings are done in an element-wise way.

fig
Handle of a graphical figure.

axes
Handle of an axes.

Description

This function can be used to modify the value of a specified property from a graphics entity or a GUI object. In this case it is equivalent to use the dot operator on a handle. For example, set(h,"background",5) is equivalent to h.background = 5.

To get the list of all existing properties, please see the pages of graphics_entities or uicontrol_properties for User Interface objects.

set(h, prop, val) or h(prop) = val or h.prop = val sets the property prop of the handle h to the value val..

When h is a matrix of handles,

  • if val is a matrix of same size: assignments are done in a element-wise way: set(h, prop, val) sets h(1)(prop)=val(1), h(2)(prop)=val(2), ..., h($)(prop)=val($). Most often, the simpler syntax h(tag) = val does it as well.
  • otherwise: The same and whole val value (that may be scalar or not) is assigned to every h(i)(prop) component.
    If val is a cell array of same size as h, it is assigned as a whole as well. For instance, set([gcf() gca()], "user_data", {"Text", 1}) will do gcf().user_data = {"Text", 1}, gca().user_data = {"Text", 1}, not gcf().user_data = "Text", gca().user_data = 1.

With this syntax, prop can't be an array of property names. To set multiple properties with a single call to set(..), the following syntax must be used.

set(h, prop1,val1, prop2,val2, ..) sets the property prop1 of the handle(s) h to the value val1, its or their property prop2 to the value val2, etc. If h and some val# are matrices of same size, element-wise assignments are done for the related prop# properties, as already described for the set(h, prop, val) syntax.

set(tagsPath, prop,val) or set(tagsPath, prop,val, prop2,val2, ..) identifies the targeted component(s) through their .tag property according to tagsPath, instead of through their handle, and then sets its properties.

In case of multiple entities matching the path, only the first one is processed. Conversely, finding no matching entity yields an error.

set("current_figure", fig) sets the figure of handle fig as the active figure. This syntax is equivalent to scf(fig) or scf(figure_id), that are shorter and may be prefered.

set("current_axes", axes) sets the axes of handle axes as the active one. This syntax is equivalent to sca(axes) that is shorter and may be prefered.

set("current_entity", h) sets the graphical component whose h(1) is the handle as the current component, as returned by gce(). If h is a vector of handles, other components h(2:$) are ignored.

Examples

gda().auto_clear = "off";
clf
// Example with a Plot 2D
x = [-.2:0.1:2*%pi]';
plot2d(x-.3, [sin(x-1) cos(2*x)], [1 2] );
a = gca();
p1 = a.children.children(1);
p2 = a.children.children(2);

// set the named properties to the specified values on the objects
p2.thickness = 2;
set(p2, "foreground",13, "polyline_style",2);
a.y_location = "middle";
a.tight_limits = "on";
set(a, "box","off", "sub_tics",[7 0]);
set(p1, "mark_mode","on", "mark_style",3);

plot2d(x-2,x.^2/20);
p3 = a.children(1).children;
set([a p1 p2 p3], "foreground",5);

With a vector of handles:

// With distinct element-wise inputs:
clf, plot2d()
[gcf() gca()].tag
set([gcf() gca()], "tag", ["myFigure" "myAxes"]);
[gcf() gca()].tag
--> [gcf() gca()].tag
 ans  =
!  !
!  !

--> set([gcf() gca()], "tag", ["myFigure" "myAxes"]);

--> [gcf() gca()].tag
 ans  =
!myFigure  !
!myAxes    !

// With the same input for all recipients:
clf, plot()
curves = gce().children;
set([gca() ; curves], "thickness", 2);
curves(1:20).thickness = 1; // shorter than set(curves(1:20), "thickness", 1)

Using a tagsPath :

f = figure("dockable", "off", "menubar", "none", "toolbar", "none", "infobar_visible", "off", "tag", "mainfig");
frameHandle = uicontrol("parent", f, "style", "frame", "position", [200 200 190 100], "tag", "myframe");
btnHandle = uicontrol("parent", frameHandle, "position", [20 20 150 30], "string", "button", "tag", "example");

set("mainfig/myframe/example", "string", "complete path");
get("mainfig/myframe/example", "string")
set("mainfig/*/example", "string", "wildcard path");
get("mainfig/*/example", "string")
set("myframe/example", "string", "partial path");
get("myframe/example", "string")

See also

  • get — Gets the handle of a graphical or User Interface object, or the property's value of objects.
  • scf — set the current graphic figure (window)
  • sdf — reSets the properties of the Default Figure to their factory values
  • sca — set the current axes entity
  • sda — reSets the Default Axes to its factory values
  • delete — delete a graphic entity and its children.
  • copy — copy a graphics entity.
  • move — move, translate, a graphic entity and its children.
  • graphics_entities — description of the graphics entities data structures

History

VersionDescription
5.5.0
  • First input argument can now be a path pointing to the graphic entity.
  • Multiple property setting is now available at once.
Report an issue
<< get property text >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Mar 27 11:52:45 GMT 2023