Chandra X-Ray Observatory (CXC)
Skip to the navigation links
Last modified: 27 November 2012

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> 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, ["symbol.style", "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 = "{0} {1}".format(os.getlogin(), time.asctime())
chips> add_label(0.95, 0.05, txt, ["coordsys", FRAME_NORM, "halign", 1])
chips> set_label(["color", "brown"])

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 Fri Sep 23 16:26:07 2011' is at the bottom-right of the visualization]


Last modified: 27 November 2012
CXC logo

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