Transforms examples

Am I correct that you would like to add new kinds of plots to matplotlib that transform the raw data in some new way? Though transforms are involved, at the higher level you see this referred to as "projections" a lot in the mpl code.

There are a number of approaches you could take, all of which have different tradeoffs, rather than there being one "Right Way".

In matplotlib-0.91 (and earlier) there is an underlying framework for doing transformations (in _transforms.cpp). This framework, while its does it job well, is kind of obscure and difficult to extend with new kinds of transformations. But it's certainly doable, and you can look at the code for polar plots (in axes.py) for an example.

As a result, the current SVN trunk has been heavily refactored to make adding new kinds of projections easier. I'm biased because I did a lot of that work, so I wouldn't want to claim that it is significantly easier until someone else comes along and uses the new framework to build something new. (I think the soil texture triangle plot you suggest seems like it would be a reasonably good fit, though). If you decide to take this approach, there is documentation for making new projections here:

http://matplotlib.svn.sourceforge.net/viewvc/*checkout*/matplotlib/trunk/matplotlib/doc/devel/add_new_projection.rst

Again, that documentation has largely gone unused by anyone but myself, so please let me know where it needs improvement. Of course, the downside is that it may be a number of months until the SVN trunk is released as a stable version.

Alternatively to all of the above, you could take the approach of "basemap" (a toolkit extension to matplotlib). It (essentially) does all of the transformation of the data into a given projection internally and then passes that along as a regular Cartesian 2D plot to matplotlib. That approach does work well, and has shown to be rather robust to internal changes in mpl, since it primarily uses the "public" (and more stable) APIs.

Hope that helps. Please ask if you have any more questions as you go.

Mike

Chloe Lewis wrote:

ยทยทยท

I stick to releases, so, 0.91.2; although if the transforms are about to change a lot, maybe I'll put off the 'right way'.

The first thing I'm writing is an easy version of the 'soil texture triangle' -- plotting x+y+z=100, but on an equilateral triangle:

http://www.uwsp.edu/geo/faculty/ritter/glossary/s_u/soil_texture_triangle.html

Scatters and patches on this are handy.

There's another handful of triangular, sort-of-rigorous 3-variable graphs commonly used by ecosystem scientists, which I'd like to extend to.

&C

On Mar 7, 2008, at 7 Mar, 10:30 AM, Michael Droettboom wrote:

Can you be a bit more specific about what you're trying to do? (Are you working with the latest SVN trunk, or the latest release 0.91.x? The two are considerably different wrt to the transforms framework(s)).

Cheers,
Mike

Chloe Lewis wrote:

Any current transforms examples? The transforms docs suggest looking in /units for transforms examples; the current matplotlib examples has /units without transforms. (I want something a bit more detailed than the offset.)

If the transforms are currently too much in flux, I'll do something one-off, but I'd like to do it the Right Way if I can.

&C

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

This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA