[GRASS-dev] matplotlib example script
Michael Barton
michael.barton at asu.edu
Thu Jul 24 12:12:41 EDT 2008
I've attached an example script and output for using the MatPlotLib
Python library in GRASS. This script replicates the functionality of
d.histogram, but makes a much nicer looking plot. It also has more
options, although I've included only a very few of the formatting
possibilities here. The script sends the output from r.stats into 9
lines of code to produce the histogram with formatting options. Most
of it is done by 4 lines. This can be run from the command line and
does not require a GUI to be installed. It writes to a PNG file, but
could easily be set to create a TclTk or wxPython interactive window
as a user-selectable option.
The following command produces the attached histogram:
histogram_mpldemo.py input=elevation.10m bins=25 output="/users/
cmbarton/documents/myhistogram" fillcolor=20:20:200
Maybe I'll try an xy graph of 2 maps/images with density plot options
next.
To run this, you need to install MatPlotLib <http://matplotlib.sourceforge.net/
>, which requires Numpy <http://numpy.scipy.org/>. Both are
installable as binary eggs via the Python easy_install package manager
or from most Linux package managers. Of course you need Python too.
Enjoy
Michael
____________________
C. Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
Phone: 480-965-6262
Fax: 480-965-7671
www: <www.public.asu.edu/~cmbarton>
-------------- next part --------------
Skipped content of type multipart/mixed
More information about the grass-dev
mailing list