3dgraph.py - A Python 3D Graph Package

by Ben-chin K Cha

Introduction

The GUI python program 3dgraph.py is a 3D plot package for graphically displaying image or specturm data in a flexible and comprehensible fashion. Any column/row oriented ASCII text data file can be easily loaded into this program. It allows user easily to extract ROI from loaded data array.

It provides various type of multiple line spectums, colored spectrum, surface or mesh plots in a 3D coordinates.

The Python Pmw color spectum is used to display the row / step wize spectrum data. A user can transpose row / step wize data freely by a simple mouse press.

Please refer 3dgraph reference file for the list of all methods defined in the Graph3D class.

Download

pviewer.zip (0.126MB) A collection of 1D/2D/3D graphic programs for python package

System Reguirement

In addition the files from pviewer.zip library, the python Tkinter, Pmw, Numeric, and PIL python sub-packages must also be installed and accessible by user python system.

Python System Requirement

	Tkinter  - python Tkinter with tk/tcl library
	Pmw 	- python mega widget class library
	Numeric - python numeric library
	PIL	- python image library

System Setup Requirement

For Unix users, a user only need to to do the following to properly setup the environment and run 3dgraph.py:
	source /APSshare/setup_apsshare
	3dgraph.py
For Linux users, a user only need to to do the following to properly setup the environment and run 3dgraph.py:
	source /APSshare/setup_linux
	3dgraph.py

Files Used

3dgraph.config - The configration file is used for easy startup of this program. This configuration file is also shared by plot2d.py and tv.py for directly passing iamge data to 3dgraph.py graphics program.

CT.dat - This file contains the 41 set of scientific color tables available for use.

SH - This file records the default font and printer used.

Ascii *.txt - The Ascii data file must be column or row oriented data set, each line should contain same number of data points, the lines start with "#" or ";" will be treated as comment. By default the column oriented data set is assumed, a user can easily convert column or row oriented data by transpose the data array.

User Interface

It consists of top menu bar, drawing area, panel of image information, command button area, and message bar area. The user interface is briefly given below:

Main window consists of a menu bar, spectrum and surface canvas plot area, a panel of image information, command buttons area, and message status area.

File Menu

	Open Ascii File... - dialog to load column oriented ascii input file 
				and display color spectrum multi-row plot
	Printer...	   - dialog to override default printer

Setup Menu

	Display Ascii File... - display the contents of ascii file loaded in
	Transpose X,Y         - transpose X,Y axis and replot the multi-row plot
	Clear Canvas Plot     - clear the plot in drawing area
	Show Edge Line        - checkbutton for displaying edge line on step  
                          	multi-line plot
	Display Rebin Array   - checkbutton affects large ascii data array, 
				whether use 200x200 bins or not 

SpectrumColor Menu

	Surface Shading           - row spectrum color shaded surface plot
	Surface Shading (stepwise) - step spectrum color shaded surface plot 
	Surface Plot              - colored spectrum polygons surface plot 
	Surface with Vertical Bar - colored spectrum with vertical bar skirt

ColorTable Menu

	Change Color Table... - dialog to show surface in picked color table
	Use Rainbow+White Color Table - show surface in rainbow + white color table
	Average Cell Color On - check button to use average cell color value

MeshLine Menu

	Surface Mesh Plot       - plot as meshed grid lines
	All Row Lines           - plot as multiple horizontal rows
	All Step Lines          - plot as multiple vertical step rows
	Pick Row Lines...       - dialog to plot desired Y step indecies
	Pick Step Lines...      - dialog to plot desired X step indecies

Help Menu

	About...                - show program info
	Balloon Help            - checkbutton to show balloon info
	3dgraph_help.txt...     - display this help info

3D Spectrum/Surface Plot Canvas

Main 3D graphic canvas area is used to display various kinds of colored spectrum, mesh lined and surface plot.

Image Info Panel

The maximum and minimum value is dranwn in this area to reflect the image array range. An image display frame is designed to show the TV image of input data array. A mouse motion event is bind with the image plot to reflects the X,Y,Z value of the mouse cursor.

Commad Area

	Print 	- send the main canvas plot to printer
	Close	- exit this program
	ROI...	- dailog to extract region of interest form image array

Message Info Area

Display the menu/button function information.

Sample Results

Following figures shows the primary features avaialbe in 3dgraph.py.

A typical Ascii text file of column oriented 2D image data generated by MDA report generation is used in this example.

Display Ascii File..

Following figure shows the contents of loaded in Ascii file. Column 1 contains X values and column 2 contains step index, image data start from column 3.

Raw Spectrum Plot

Following figure shows the spectrum plot of the raw Ascii data. The image in right panel show the complete data columns read in including the first two columns contains the X values and index vectors. In this case the bottom two rows reflect the X values. By default the spectrum line edge is also plotted.

Note that the input data is converted internally into rows of step wise data. The independent spectrum data starts from 3rd row(column) from bottom in this image display.

Dialog ROI ...

Following figure show how to throw away X column values from the image area. The 'ROI...' dialog allows the user extract only region of interest from the right panel image area.

Following figure show the X vectors have been stripped away from data array, ie, true spectrum/image data array from 3 to 43 rows.

Surface Mesh Plot

Following figure show the 3D mesh plot of image data.

Color Table Dialog ...

Following figure show the dialog of pick pre-defined color table available for the program.

Following figure show the rainbow + white color table used in 3D surface plot.

Spectrum Surface Shading

Following figure show the color shading of 3D specturm plot by using the Pmw.Color.spectrum color scheme.

Step Slices Dialog ...

Following figure show the dialog of picking step number slices to be plotted in 3D coordinates.

Following figure show the line spectrum in 3D coordinates.

Upper Right Quadrant ...

Following figure show the ROI... dialog for extract upper right quadrant from image area.

Following figure show the spectrum with edge plot of the upper right quadrant of the data array.

Following figure show the mesh plot of the upper right quadrant of the data array.