| AHELP for CIAO 4.5 ChIPS v1 | add_colorbar |
Context: images |
Synopsis
Create a colorbar for an image
Syntax
add_colorbar([ChipsId,] x, y [,object_id] [,attributes]) Color bars can also be created directly from the GUI using the "Annotate" menu item.
Description
A colorbar displays the mapping from pixel value to color intensity in the associated object, such as an image.
- ChipsId - an optional ChipsId structure containing values to modify the currency state for the command.
- x - the location for the center of the colorbar along the horizontal axis. The default coordinate system is PLOT_NORM.
- y - the location for the center of the colorbar along the vertical axis. The default coordinate system is PLOT_NORM.
- object_id - a ChipsId structure indicating which object should be modified
- attributes - optional parameters which allow the user to configure properties though a structure, list, or attribute string.
The add_colorbar command creates a colorbar whose attributes are specified by user preferences or in an attribute list. The new colorbar becomes current by default; providing a ChipsId overrides the currency state.
Customizing the Colorbar
There are several attributes that control the colorbar characteristics. The attributes can be set to the ChIPS defaults, values provided in the add_colorbar command, or values from the user's preference file.
The attributes may also be modified with the set_colorbar command at any time; see "ahelp set_colorbar" and "ahelp setget" for more information.
Please see the section "Colorbar Preferences and Attributes" below the examples for a list of the colorbar preferences.
Example 1
chips> add_colorbar(0.5, 1.05)
Adds a colorbar above the plot.
Example 2
chips> add_colorbar(0, 0.5, "orientation=vertical")
Create a vertical colorbar at the left edge of the plot.
Example 3
chips> add_colorbar(0.8, 0.45, ["length", 0.4, "orientation", "vertical"]) chips> set_colorbar(["width", 0.08])
Add a vertical colorbar, with height 40 per cent that of the plot, centered on the plot-normalized coordinates of (0.8,0.45). The width of the bar is then changed to 0.08.
Example 4
chips> add_colorbar(0, .5, "id=vert orientation=vertical")
chips> set_colorbar("label.text=chandra")
chips> set_colorbar("label.location=outside tick.location=inside")
chips> set_colorbar("tick.color=lime ticklabel.color=lime")
chips> c = get_colorbar()
chips> c.label.text = "nvss"
chips> c.orientation = 1
chips> add_colorbar (1.05, .5, c)A colorbar is created and several attributes are set. A ChipsColorBar object, "c", is created by retrieving the colorbar attributes with get_colorbar. The text and orientation are changed, then another colorbar is created to match the existing one.
Colorbar Preferences and Attributes
The attributes associated with colorbars are given in the following table, where the "Set?" column refers to whether the attribute can be changed using the set_colorbar() command. To change the colorbar preference settings prepend "colorbar." to the attribute name.
| Attribute | Description | Options | Default | Set? |
|---|---|---|---|---|
| border.visible | should the border of the colorbar be visible? | see the Booleans section of "ahelp chipsopt" | true | Yes |
| depth | the depth of the colorbar | see the Depth section of "ahelp chipsopt" | default | Yes |
| halign | horizontal alignment of the colorbar | auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" | center | Yes |
| label.angle | angle, in degrees, of the label | -360.0 to 360.0 | 0 | Yes |
| label.color | color of the label | name or hex; see the Color section of "ahelp chipsopt" | default | Yes |
| label.font | font for the label | helvetica|courier|times|greek; see the Font section of "ahelp chipsopt" | helvetica | Yes |
| label.fontstyle | style for the label | normal|bold|italic|bolditalic; see the Font Style section of "ahelp chipsopt" | normal | Yes |
| label.halign | horizontal alignment of the label | auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" | auto | Yes |
| label.location | which side of the colorbar does the label appear on, relative to the plot center? | outside|inside | inside | Yes |
| label.size | size of the label | 1 to 100 | 12 | Yes |
| label.text | text for the colorbar label | Yes | ||
| label.valign | vertical alignment of the label | auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" | auto | Yes |
| label.visible | should the label be visible? | see the Booleans section of "ahelp chipsopt" | true | Yes |
| length | the length of the colorbar, in plot-normalized coordinates | A real number, greater than 0. | 1 | Yes |
| offset.parallel | shift of the label from the center of the colorbar | -0.5 to 0.5 inclusive; 0 is the center and -0.5/+0.5 refer to the edges | 0 | Yes |
| offset.perpendicular | shift of the label from the edge of the colorbar (in pixels) | -100 to 100, inclusive | 5 | Yes |
| orientation | orientation of the colorbar | "horizontal" or "vertical" | horizontal | Yes |
| stem | stem to use for colorbar ids | An alpha-numeric character sequence that does not contain a space | cbar | No |
| tick.color | color of the tickmarks | name or hex; see the Color section of "ahelp chipsopt" | default | Yes |
| tick.length | length of the tickmarks | Non-negative integer | 4 | Yes |
| tick.location | should the ticks and labels appear on the outside or inside of the colorbar with reference to plot center? | inside|outside | outside | Yes |
| tick.mode | mode for calculating tickmark locations | arbitrary|count|interval|limits|nice; see the Tick Mode section of "ahelp chipsopt" | nice | Yes |
| tick.style | should the tickmarks extend into the colorbar, point out of the colorbar, or both (inside, outside, or centered)? | inside|outside|centered; see the Tick Style section of "ahelp chipsopt" | inside | Yes |
| tick.thickness | thickness of the tickmarks | 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" | 1 | Yes |
| tick.visible | should the tickmarks be visible? | see the Booleans section of "ahelp chipsopt" | true | Yes |
| ticklabel.angle | angle, in degrees, of the tickmark labels | -360.0 to 360.0 | 0 | Yes |
| ticklabel.color | color for the numeric tickmark labels | name or hex; see the Color section of "ahelp chipsopt" | default | Yes |
| ticklabel.font | font for the tickmark labels | helvetica|courier|times|greek; see the Font section of "ahelp chipsopt" | helvetica | Yes |
| ticklabel.fontstyle | style for the tickmark labels | normal|bold|italic|bolditalic; see the Font Style section of "ahelp chipsopt" | normal | Yes |
| ticklabel.halign | horizontal alignment of the tickmark labels | auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" | auto | Yes |
| ticklabel.offset | separation, in pixels, of the tickmark labels from the colorbar | Non-negative value | 6 | Yes |
| ticklabel.size | font size of the numeric tickmark labels | 1 to 100 | 12 | Yes |
| ticklabel.valign | vertical alignment of the tickmark labels | auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" | auto | Yes |
| ticklabel.visible | should the tickmark labels be visible? | see the Booleans section of "ahelp chipsopt" | true | Yes |
| valign | vertical alignment of the colorbar | auto|base|center|left|right|top; see the Text Alignment section of "ahelp chipsopt" | center | Yes |
| width | the width of the colorbar, in plot-normalized coordinates | Non-negative value | 0.05 | Yes |
Changes in CIAO 4.5
Color bars can now be added directly from the GUI, using either the "Annotate" menu item or the "Annotate" option brought up by using the Right-Mouse Button in the ChIPS window.
Coordinate system support
It is now possible to set the coordsys attribute of annotation objects - i.e. those created by ChipsLabel(), ChipsLine(), ChipsPoint(), ChipsRegion(), and ChipsColorBar() - to define the coordinate system used to create the object. So the following will add a label - of the current time - to the bottom-right corner of the frame.
chips> l = ChipsLabel() chips> l.coordsys = FRAME_NORM chips> l.halign = 1 chips> import time chips> add_label(0.95, 0.05, time.asctime(), l)
Bugs
See the bugs pages on the ChIPS website for an up-to-date listing of known bugs.
See Also
- chips
- chips, chipsgui, chipsrc, show_gui
- concepts
- aspectratio, attributes, chipsid, chipsopt, colors, coordsys, currency, depthcontrol, entitycreation, preferences, setget
- images
- current_colorbar, delete_colorbar, display_colorbar, get_colorbar, hide_colorbar, move_colorbar, set_colorbar, shuffle_colorbar

![[ChIPS Logo]](../imgs/chips_logo_navbar.gif)