Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: December 2013

URL: http://cxc.harvard.edu/chips/ahelp/get_plot_range.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.9 ChIPS v1

get_plot_range

Context: limits

Synopsis

Retrieves the range of the current axes or axis of the current plot.

Syntax

get_plot_range([id])
get_plot_xrange([id])
get_plot_yrange([id])

Description

The function arguments.

Argument Description
id A ChipsId structure identifying the item, or a string containing the name of the object.

The get_plot_range command returns the X and Y ranges of the current axes of the current plot. The values are returned as [xmin, xmax, ymin, ymax]. The get_plot_xrange and get_plot_yrange versions just return the limits for the X or Y axis, respectively.

There are also versions of this command for getting the ranges of curves, histograms, and contours: get_curve_range(), get_histogram_range(), get_contour_range() and variants thereof.

Example 1

chips> clear()
chips> x = np.asarray([1, 2, 3, 4, 5])
chips> y = x**2
chips> add_curve(x, y)
chips> print(get_plot_range())
[0.8, 5.2, -0.20000000000000018, 26.2]
chips> print(get_plot_xrange())
[0.8, 5.2]
chips> get_plot_yrange()
[-0.20000000000000018, 26.2]
chips> set_axis(["pad", 0])
chips> print(get_plot_range())
[1.0, 5.0, 1.0, 25.0]
chips> print(get_plot_xrange())
[1.0, 5.0]
chips> print(get_plot_yrange())
[1.0, 25.0]

The curve y=x^2 is created for the points x=1, 2, 3, 4, 5. The X axis range of the plot is 0.8 to 5.2 because of the default axis padding, which is added to make sure that the minimum or maximum points are not lost. If the axis padding is set to 0 then the plot ranges match the curve range.

Example 2

chips> clear()
chips> add_curve("data1.dat")
chips> add_plot()
chips> add_curve("data2.dat")
chips> get_plot_range("plot1")
[40010.099999999999, 51557.900000000001, 16.148500000000002, 32.6815]
chips> get_plot_xrange("plot1")
[40010.099999999999, 51557.900000000001]
chips> get_plot_yrange("plot1")
[16.148500000000002, 32.6815]

A curve is created; since no plot exists, one is created and the curve is placed in it. A second plot is created, and a different curve is added to it. The get_plot_xrange and get_plot_yrange commands are called with the id of the first plot, returning its x and y axis ranges.

Example 3

chips> id = ChipsId()
chips> id.plot = "plot1"
chips> print(get_plot_range(id))

Building on the previous example, a ChipsId structure is created and the id.plot field is set to "plot1". get_plot_range is called with the ChipsId.

Bugs

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

See Also

concepts
setget
plots
add_plot, adjust_grid_gaps, adjust_grid_xrelsize, adjust_grid_xrelsizes, adjust_grid_yrelsize, adjust_grid_yrelsizes, clear_plot, current_plot, delete_plot, display_plot, get_plot, grid_objects, hide_plot, move_plot, reposition_plot, set_data_aspect_ratio, set_plot, set_plot_aspect_ratio, split, strip_chart, swap_object_positions
utilities
set_current

Last modified: December 2013
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.