[GRASS-dev] matplotlib example script

I guess the mailbot stripped out my small attachments. So here are links for those of you interested

Script: http://www.public.asu.edu/~cmbarton/files/grass_scripts/histogram_mpldemo.py
Example output: http://www.public.asu.edu/~cmbarton/files/grass_scripts/myhistogram.png

Michael

On Jul 24, 2008, at 9:12 AM, <grass-dev-request@lists.osgeo.org> <grass-dev-request@lists.osgeo.org > wrote:

Date: Thu, 24 Jul 2008 09:12:41 -0700
From: Michael Barton <michael.barton@asu.edu>
Subject: [GRASS-dev] matplotlib example script
To: grass developers <grass-dev@lists.osgeo.org>
Message-ID: <E32185A6-9982-482A-9E3C-7E21D7F660E5@asu.edu>
Content-Type: text/plain; charset="us-ascii"

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/&gt;\. 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>