Chandra X-Ray Observatory
Skip to the navigation links
Last modified: 14 December 2016

Can I add a label to the bottom right of a plot as an id?

We can use the support for different coordinate systems to place a label outside of the main plot area. We start with a simple plot:

chips> clear()
chips> x = np.arange(100) * 0.1
chips> y = np.sin(x) * np.cos(x)
chips> add_window(8, 6, 'inches')
chips> add_curve(x, y, ['', 'none'])

and now want to place a label at the bottom-right corner of the window. Since we have a single frame that covers the window we use the frame-normalized coordinate system, and place a label at a coordinate of (0.95,0.05); we use halign to move the reference point of the label so that this position refers to the right edge of the text (i.e. it is right-aligned).

chips> import time
chips> txt = "{} {}".format(os.getlogin(), time.asctime())
chips> add_label(0.95, 0.05, txt, ['coordsys', FRAME_NORM, 'halign', 1])
chips> set_label(['color', 'brown', 'size', 18])

The result is shown below. We had to import the time module to get the current time; the os module is pre-loaded by ChIPS so we can use it to get the user's name for the label.

[The label 'ciaouser Mon Dec  8 11:58:46 2014' is at the bottom-right of the visualization]

Last modified: 14 December 2016
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.