[GRASS-dev] Re: Python MatPlotLib histogram example

Glynn Clements glynn at gclements.plus.com
Wed Jan 30 10:05:25 EST 2008


Moritz Lennert wrote:

> > I spent a little time playing around with the Python statistical 
> > graphing library MatPlotLib this evening. I've attached a screenshot of 
> > a demo histogram and, below, the code needed to create it. This example 
> > uses TkInter, but it isn't much more complicated to put this into 
> > wxPython. This seems pretty cool. There are much nicer plots too.
> 
> Great !
> 
> Could we try to make it as a general rule for such tasks (e.g. I'm also 
> thinking about the profiler...) we isolate the code of the actual 
> drawing function to make it callable from the GUI and the command line ?

Definitely. There's no good reason why such functionality should only
be available on desktop systems.

Unfortunately, although MatPlotLib isn't limited to GUI use, it isn't
going to integrate well with the GRASS display system. E.g. there
doesn't appear to be any practical way to make it send its output to
"wherever d.* commands send their output". So, non-GUI tasks will need
to manually integrate anything done using MatPlotLib with the output
from d.* commands.

> Glynn, will what you have in mind for the new display system also allow 
> this for things like more sophisticated scalebar and legend placement 
> from the command line on the basis of the python code used in the GUI ?

The display system operates at the level of lines, polygons, text,
etc. If you want an axis with labelled ticks, you draw a big line for
the axis, lots of little lines for the ticks, text for the labels,
etc. That's the job of display modules such as d.histogram; the
display system just provides the raw primitives.

Axes, scales, etc are probably useful to enough different tasks that
it may be worth having library functions for them, but that would be
above the level of the display system itself.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list