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

URL: http://cxc.harvard.edu/chips/ahelp/ChipsAspect.html
Jump to: Description · Example · See Also


AHELP for CIAO 4.9 ChIPS v1

aspectratio

Context: concepts

Synopsis

A discussion of the aspect ratio support in ChIPS.

Description

There are two distinct aspect ratios in ChIPS: plot aspect ratio and data aspect ratio. ChIPS allows users to set their own aspect ratios via the set_plot_aspect_ratio function and the set_data_aspect_ratio function.

This document discusses the technical details between the two aspect ratios and explains how ChIPS applies each to a plot.

Plot Aspect Ratio

Setting the plot aspect ratio in ChIPS means that the area described as the plot will maintain the ratio of width to height even as area allotted to plot changes. This includes changing the window size, changing frame size or gridding the frame into multiple plots. Algorithmically, the plot area will expand to the largest possible area as defined by the plots margins, while maintaining the aspect ratio specified. This means that either the width or the height will expand to the plot margins and the counterpart (height or width, respectively) will fill only some percentage of the area defined by the plot margins. The resized plot area will always be calculated about the center of the plot.

Note that even as the plot area changes, the margins which help define that area do not. This means that the border axes do not necessarily represent the margins when the aspect ratio is turned on. However, they alway represent the maximal plot drawing area.

Data Aspect Ratio

The data aspect ratio is the ratio which is used to force the plot to maintain a consistency in the amount of data being displayed along the x and y axes despite the size plot area itself. This means that as the plot area's dimensions are changed, the limits described by the axes must adjust accordingly to meet the demands of the data aspect ratio so that the range of the limits along the x and y axes match the aspect ratio.

Algorithmically, ChIPS does this initially by keeping the x-axis as the stable axis and adjusting the y axis limits around it. That is, when the data aspect ratio is first set, the limits of the x axis remain as is. The limits of y axis are recomputed based on the what the range should be given the range of the x axis and the aspect ratio. Then the y axis limits are set to expand the range as calculated, maintaining the center of the axis limits.

If the limits of one axis is changed and the data aspect ratio is set, the limits of the adjoining axis are automatically adjusted. To do this, ChIPS uses the axis whose limits have been explicitly modified as the base and recomputes the other axis range based on those limits and the aspect ratio. This time, however, the center of the axis is the center of the data range. For this reason, we do not allow a single limit range to be run on XY_AXIS. If the aspect ratio is anything other than 1:1 the limits don't make sense.

While a single limit can not be set for both x and y axis. The individual x and y axes can be set simultaneously: limits (x1,x2,y1,y2). In this case, the x axis range is used as the base and the y axis range is calculated from it. The center of the y axis in this case is the center of the specified range of the y axis.

Other times that the limits are re-adjusted are when automin, automax pad, major mode, minor mode minor num, tickformat, major interval or minor interval are changed. In this case the center of the adjoining axis is recentered based on the data range of that axis.

Lastly, if automin and automax are on and a new plot object is added to the plot area which changes the limits, the limits are recalculated and centered similarly. In this case each axis has its limits recalculated. In this case the it's a little bit redundant, but the algorithm adjust each axis with one set of limits followed immediately by updates to all adjoining axes. The centering is done on the axis limits at that time. So if the plot has axes ax1 and ay1, then it changes the limits of ax1 according to the new data and updates ay1. It then changes the limits of ay1 and updates ax1.

So what happens when the limits stay the same and the plot area is adjusted? In this case the limits are recalculated so that the area displayed either zooms in or out, depending on whether you are expanding or shrinking the plot area. If the plot aspect ratio is set, the limits will not change. The display will grow appropriately as if you were simply enlarging or shrinking an image.

Example

chips> img = np.arange(150).reshape(10,15)
chips> split(2, 1, 0.1, 0)
chips> add_image(img)
chips> current_plot('plot2')
chips> add_image(img)
chips> set_plot_aspect_ratio('fit')
chips> print(get_plot_range('plot1'))
[-0.6538464712673528, 16.65384647126735, 1.7499998509883818,
9.250000149011619]
chips> print(get_plot_range('plot2'))
[0.5, 15.5, 0.5, 10.5]

In the top plot the axes do not match the data; the X axis is larger than the image and the Y axis is smaller, since the aspect ratio of the plot created by the split command does not match the 1.5:1 ratio of the image. The second plot has been adjusted to match the data by the set_plot_aspect_ratio command.

See Also

chips
chips, chipsgui, chipsrc, show_gui
concepts
attributes, chipsid, chipsopt, colors, coordsys, currency, depthcontrol, entitycreation, preferences, setget

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.