Last modified: December 2013

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.11 ChIPS v1


Context: coordinates


Converts a point from one ChIPS coordinate system to another.


convert_coordinate(point, in_coord)
convert_coordinate(point, in_coord, out_coord)
convert_coordinate(point, in_coord, out_coord, axis)


The function arguments.

Argument Description
point The coordinate to convert (a scalar or two-element container).
insys The coordinate system of point; if not given the current coordinate system is used.
outsys The coordinate system of the answer; if not given the current coordinate system is used.
axis This argument is only used if point is a scalar value, and determines the axis of the coordinate transform to use. Valid values are X_AXIS or Y_AXIS.

The convert_coordinate command converts a point from one ChIPS coordinate system into another. The conversion can be performed between any coordinate systems which have been created. For example, the value of a point in data system coordinates can be converted to the data system from a different plot.

The output of this command is the input point value(s) represented in the specified output coordinate system. If the input is a single value, a single value will be returned. Otherwise a coordinate pair will be returned.

Coordinate systems

The input and output coordinate systems are specified as an enumerated type, a string, or a ChipsId. If no system is given, the current coordinate system is used.

The allowed enumerated types include PIXEL, WINDOW_NORM, FRAME_NORM, PLOT_NORM or DATA; see "ahelp coordsys" for more information.

If a string is supplied, it should be the name of a data system. The command will look for the specified data system in the current plot. Alternatively, a ChipsId can be supplied to specify the coordinate system from any window, frame or plot.

Keyword arguments

Keywords can be used in the argument list as a method of not setting arguments which come earlier in the argument list. For example

convert_coordinate((5,6), out_coord=PLOT_NORM)

specifies that the output should be in plot normalized coordinates and that input is the in current coordinate system (the default setting).


Example 1

chips> add_window(360, 360, 'pixels')
chips> print(convert_coordinate((180, 180), PIXEL, WINDOW_NORM))
[ 0.5 0.5]
chips> print(convert_coordinate((.5,.5), WINDOW_NORM))
[ 180. 180.]

Add a window which is 360x360 pixels; the default coordinate system for a window is always pixels). Convert the point (180,180) pixels into window normalized coordinates; the result should be (.5,.5). Then convert (.5,.5) from window normalize coordinates into the current coordinate system.

Example 2

chips> clear()
chips> x = np.arange(-np.pi, np.pi, 0.02)
chips> y = np.random.gamma(2, 0.5, size=x.size)
chips> add_curve(x, y, ['', 'noline'])
chips> yn = convert_coordinate(y.max(), DATA, PLOT_NORM, Y_AXIS)
chips> lopts = { 'coordsys': PLOT_NORM, 'halign': 1}
chips> add_label(0.95, yn, 'LABEL', lopts)

Here we plot up data points (a random distribition) and then use convert_coordinate to convert the maximum Y value to plot-normalized coordinates. This coordinate is then used to place a label in the right-hand corner of the plot.

Example 3

chips> add_curve([1,2,6,7], [6,13,2,6])
chips> pnt = convert_coordinate([2,13], out_coord=PLOT_NORM)
chips> id = ChipsId()
chips> id.coord_sys = PLOT_NORM
chips> add_point(id, pnt[0], pnt[1], 'color=red')
chips> limits(X_AXIS, 0, 8)

Create a curve and use convert_coordinate to determine where the data value (2,13) is in plot normalized coordinates. The keyword out_coord was used in order to bypass having to set the input coordinate, which means that the current coordinate system is used (i.e. the data coordinate system used to display the curve). Store the returned value and use it to create a point in plot normalized coordinates. The limits command changes the X axis, so after this call the point no-longer overlaps the curve.


See the bugs pages on the ChIPS website for an up-to-date listing of known bugs.

See Also