AstroPy - plots.py


Description

This file contains classes for PlotFrame (1d plot), Plot2Frame (2d plot), and ImageFrame (2d array/image), all of which are written using WxPython graphics. 1d and 2d plots can contain one or more curves. A single curve can have selected points highlighted. The image window constructs a fixed pixmap, and can additionally draw a set of points, lines, circles, and rectangles over the image at the correct floating-point (nearest) pixel coordinates. A wx application must be created before creating any of these classes, and at least one window must be created. Each object is a derivative of wx.Frame, and responds to those commands as well.

Usage

PlotFrame(data, title='1d plot', min=0, max=0, pos=(-1, -1), size=(500, 422), selected=None, xoffset=0.0)
   Create a new 1d plot with floating-point data (a 1d or 2d numpy array).  For multiple
   curves, each row of a 2d array is a separate curve.  Set min = max = 0 for autoscaling.
   For a single curve, selected is a 1d array of booleans indicating which points to highlight.
   xoffset determines where the curves start along the x axis (0.0 to 1.0), with all points 
   distributed in the remaining space.
   
reload(data, title=None, min=0, max=0, selected=None, xoffset=0.0)
   Plot new data.

-----------------------

Plot2Frame(data, title='2d plot', min=(0, 0), max=(0, 0), pos=(-1, -1), size=(500, 522), selected=None)
   Create a new 2d plot with floating-point data (a 2d or 3d numpy array).  A curve is a 
   2 x N array of points.  For multiple curves, each sheet (first index) of a 3d array is 
   a separate curve.  Set min = max = 0 for autoscaling.  For a single curve, selected is 
   a 1d array of booleans indicating which points to highlight.
   
reload(data, title=None, min=(0, 0), max=(0, 0), selected=None)
   Plot new data.

-----------------------

ImageFrame(data, title='Image plot', min=0, max=0, pos=(-1, -1), pts=None, circ=None, circ2=None)
   Create a new image plot with floating-point data (a 2d numpy array).  Set min = max = 0 
   for autoscaling.  pts is a 2 X N array.  circ and circ2 are (cx, cy, rad) tuples.
   
reload(data, title=None, min=0, max=0, pts=None, circ=None, circ2=None)
   Plot new data.
   
addPoint(im, pt, val)
   Plot a point (set to val) in an image (2d array).  pt is an (x, y) tuple.

addLine(im, x1, y1, x2, y2, val)
   Plot a line (set to val) in an image (2d array).
   
addCircle(im, circ, val)
   Plot a circle (set to val) in an image (2d array).  circ is a (cx, cy, rad) tuple.

Examples

Calling the program from the command line creates examples of each window:

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

See the __main__ section of the file for examples of creating the individual plots.


©Sky Coyote 2007