Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: 13 March 2017

How can I set the axis scaling of plots to linear or logarithmic?


Within the Sherpa session, the following commands may be used to set the scale of plots to either linear or logarithmic. Note that the set_* commands allow you to specify that only certain types of plots be affected by the scaling setting, e.g., only data or model plots, as opposed to having all plots created in the session altered.

When called with no arguments, these commands will set the scale of all plots created in the session; otherwise, they will alter only the specified plot type, e.g., 'set_xlog("data")' to set the X axis of only data plots to log scale. These commands take effect when issued before the desired plot is generated; i.e., these commands will not alter a plot which has already been created. They accept the arguments used by the generic plot command, e.g., "data", "model", "source", "fit", "delchi", etc.

These commands may be called with no arguments to adjust both the X and Y axes of a plot which has already been created, or with either of the "X_AXIS" or "Y_AXIS" arguments to alter just one axis.

The get_model_component_plot command must be used to set the axes of plots created with the plot_model_component command.

To change the default preference settings for plot_data so that both the X and Y axes of a data plot will be drawn using a log scale each time the function is called in Sherpa, add the following get_data_plot_prefs() functions to your Sherpa customization file, located in ~/.ipython-ciao/ipythonrc-sherpa-user:

unix% more  ~/.ipython-ciao/ipythonrc-sherpa-user
# Include default Sherpa application profile
# DO NOT REMOVE THE NEXT LINE -- EVER!
include ipythonrc-sherpa
#***************************************************************************
# Add user customizations (if any) below this line:
#***************************************************************************

execute get_data_plot_prefs()["xlog"] = True
execute get_data_plot_prefs()["ylog"] = True
execute get_model_plot_prefs()["xlog"] = True
execute get_model_plot_prefs()["ylog"] = True

Note that adding the get_model_plot_prefs commands will not change the default axis scaling to logarithmic for model plots created with plot_model , it will remain linear. However, models plotted with plot_fit will be scaled logarithmically.



Last modified: 13 March 2017
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:   cxchelp@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2017. All rights reserved.