Last modified: December 2013

Jump to: Description · Examples · See Also

AHELP for CIAO 4.11 ChIPS v1


Context: concepts


Attributes are used to configure object properties such as color, font, and line style.


ChIPS allows users to control the appearance and behavior of objects - such as windows, curves, lines, contours, and axes - via configurable attribute settings. For instance, labels have a font, color, font size, font style, angle, and alignment attributes. The add_<object> and set_<object> help files have a list of the attributes for each object.


The ChIPS GUI allows you to edit the attributes of objects using a GUI rather than the command line. When in "Select" mode, clicking in the ChIPS window will highlight the object under the click (square "handles" will appear at the edges of the object). At this point, selecting the "Edit <Object>" menu item brought up by the right-menu button will create a dialog window which will let you edit the properties of the object. Alternatively, the object can be selected from the object list in the main window of the ChIPS GUI, and its attributes edited from there.

The GUI does not currently provide support for the *.name or short forms for changing multiple attributes at once.

Bringing up the GUI

The GUI can be launched by right clicking on an existing ChIPS window and selecting "Show GUI", or by running the show_gui command from the ChIPS command line.

Attribute Names

Short forms are available:

Short Form Description
*.name All elements that match name; e.g. *.color, *.font, and *.thickness.
err.* Refers to err.up, err.down, and - for curves - err.left and err.right.

These short forms can be used in attribute lists, dictionaries and strings: e.g.

set_axis(["*.color", "green"])
set_axis({"*.color": "green"})

For attribute objects the syntax is "": for example

crv = ChipsCurve()
crv.all.color = "blue"
crv.all.thickness = 2

Attribute Objects

Attribute objects are structures for setting and retrieving attribute values of objects. A blank object is created from object constructors, such as ChipsLabel, then the values are set and applied to the object.

l = ChipsLabel()
l.color = "darkred"

Values set to None have no effect on existing attribute values.

The get_<object> commands return a structure of attributes for the specifed object populated with the current values. These objects - which are the same as returned by the Chips<Object>() constructors - can be displayed, for example:

chips> i = get_image()
chips> print(i)
alpha = [1.0, 1.0]
colormap = 3
colormap_interpolate = True
colormap_size = 256
depth = 100
id = None
interpolation = 0
invert_colormap = False
scale_channels = True
stem = None
threshold = [0.0, 11.0]

Attribute Lists

Attribute lists consist of any number of attribute/value pairs. The syntax for the list is: attribute1, value1, attribute2, value2, ... attributeN, valueN.

add_curve(x, y, ["line.color", "coral"])
set_curve(["symbol.color", "red", "symbol.size", 10])

As shown, the list syntax may be used when adding a new object or when updating the settings of an existing object.

If the attribute list is specified during an add_<object> command, it may include attributes for other objects that will be created by the call, e.g. here we create a square window of width 8 inches in which the image is placed:

avals = ["window.width", 8, "window.height", 8, "window.units",
add_image("img.fits", avals)

Attribute Dictionaries

Here a Python dictionary is used, where the keys are the attribute names which store the attribute value. For instance:

add_curve(x, y, {"line.color": "coral"})
set_curve({"symbol.color": "red", "symbol.size": 10})

The attribute dictionary can be used in the same manner as the attribute list: e.g.

avals = {"window.width": 8, "window.height": 8, "window.units":
add_image("img.fits", avals)

Attribute Strings

An attribute string is a space-delimited list of attribute/value pairs which may be used to set values of object attributes. The syntax for the string is: attribute1=value1 attribute2=value2 ... attributeN=valueN.

add_curve(x, y, "axis.color=lime line.color=cornflower")

The attribute string may only be used in an add_<object> command. It cannot be used to change the properties of an existing object.

Individual Attributes

The module of advanced ChIPS functions contains lower-level commands in ChIPS to set individual object attributes (refer to "ahelp chips" for information on loading the module).

set_frame_transparency("frm1", True)

These commands are equivalent to using set_<object> with an attribute/value pair.


Example 1

chips> add_label(100, 100, "Fig. B", ["color", "blue", "size", 8])

Create a blue label, specifying the attribute values in a list.

Example 2

chips> add_label(0.05, 0.95, "Fig. C", {"coordsys": PLOT_NORM, "color":
"blue", "size": 8})

Add a blue label to the top-left corner of the plot, specifying the attributes using a Python dictionary.

Example 3

chips> x1 = [1, 1, 2, 2.32, 2]
chips> y1 = [1.5, 2, 2, 1, 1]
chips> x2 = [3, 2.67, 3]
chips> y2 = [1, 2, 2.2]
chips> add_region(x1, y1, " fill.color=blue")
chips> add_region(x2, y2, " fill.color=lime")

Add two regions, using an attribute string.

Example 4

chips> f = ChipsFrame()
chips> f.border.color = "blue"
chips> f.border.visible = True
chips> set_frame("frame1", f)

Populate the "f" structure with attribute values (turn on the frame border and make it blue), then use it to change the attributes of the frame called "frame1".

Example 5

chips> add_frame(0.1, 0.1, 0.5, 0.5)
chips> set_frame(["bgcolor", "tan"])
chips> add_frame(0.5, 0.5, 0.9, 0.9)
chips> set_frame({"bgcolor": "white"})

Two frames are created, and the background color of each is set with an individual attribute command (the first using an attribute list and the second a dictionary).

See Also

chips, chipsgui, chipsrc, show_gui
aspectratio, chipsid, chipsopt, colors, coordsys, currency, depthcontrol, entitycreation, preferences, setget
get_attribute, set_attribute, set_cascading_property