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

How do I change an axis to use a logarithmic scale?

The log_scale and lin_scale commands change an axis to be drawn using a logarithmic or linear scale, respectively (the longer forms logarithmic_scale() and linear_scale() can also be used).

chips> clear()
chips> x = np.arange(-2, 3, 0.1)
chips> y = 10**x
chips> add_curve(x, y)
chips> set_curve(["", "noline", "", "circle", "symbol.fill", False])
chips> log_scale(Y_AXIS)
[The y axis is drawn in logarithmic scale from 0.01 to 1000]

What happens to negative values?

ChIPS will allow you to convert an axis to logarithmic scale even if it displays zero or negative values; the minimum positive value of the data will be used to determine the new limits if required. With the plot from above, the minimum positive value should be 0.1 but due to numerical artifacts it is actually 1e-15, which can be seen by converting the X-axis to a logarithmic scale:

chips> x[np.where(x > 0)].min()
chips> log_scale(X_AXIS)
[The x axis now displays roughly 1e-15 to 10 using a loarithmic scale]

We can adjust the limits on both axes to avoid displaying this point; for example

chips> limits(X_AXIS, 0.05, AUTO)
chips> limits(Y_AXIS, 1, AUTO)
[The x axis now displays 0.03 to 3 and the y axis 1 to 1000]


The ChIPS GUI makes it easy to modify a visualization using your mouse, rather than Python functions. The GUI can also be used to add annotations - such as labels, lines, points and regions - and to zoom or pan into plots.

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.