AstroPy - plots.py - 9/3/07


Description

This file contains classes for PlotWindow (1d plot), Plot2Window (2d plot), and ImageWindow (2d array/image). The 2d plot can be redrawn while resizing the window, or a fixed size pixmap can be constructed once and redisplayed for speed. The image window constructs a fixed pixmap, and can draw a set of points, a circle, and a rectangle over the image at the correct floating-point (nearest) pixel coordinates (whereas the Qt graphics calls do not draw at the correct coordinates). A QApplication must be created before calling any of these classes, and the resulting window object must be saved in a Python variable (such as a window list) in order to be retained (and visible). Each object is a derivative of QWidget, and responds to those commands as well.

Usage

PlotWindow(title, data)
   Create a new 1d plot with title and data (a 1d numpy array)
   
setData(data)
   Plot new data

Plot2Window(title, xdata, ydata, mode=0, size=(512, 512))
   Create a new 2d plot with title, xdata, and ydata (2 1d numpy arrays)
   Mode = 0 for live redrawing, mode = 1 for fixed pixmap construction (at given size)
   
setData(xdata, ydata, mode=0)
   Plot new data, using redrawing or pixmap

ImageWindow(title, data, min=0, max=0, pts=None, circ=None, rect=None)
   Create a new image window with title and data (a 2d numpy array)
   Autoscale if min = max = 0, otherwise clip display to given values
   Draw a set of points (n x 2 numpy array)
   Draw a circle (tuple/list/array = (cx, cy, rad) in floating-point coords)
   Draw a rectangle (tuple/list/array = (x0, y0, dx, dy) in floating-point coords)
   
setData(data, min=0.0, max=0.0, fname=None, pts=None, circ=None, rect=None)
   Plot new data with optional min, max, points, circle, and rectangle

Examples

Calling the program from the command line creates an example of each window:

25: ~/Projects/Python/AstroPy > plots.py


İSky Coyote 2007