Present Perfect


Picture Gallery
Present Perfect


Filed under: Python — Thomas @ 2:43 pm

2:43 pm

Is python’s matplotlib and pylab just a twisty little maze of global variables and mass imports, making it impossible to learn your way around by introspection ? Or is it me ?

I am getting lost in the difference between Axes, figure()’s and plot()’s…

I’m sure this would all make more sense to me if I could recall my vague Matlab knowledge from university.


  1. It’s a bit awkward, but it works well enough. Are you trying to figure out how to use it or hack it?

    Comment by Bryan — 2009-6-5 @ 4:19 pm

  2. pylab pulls all sorts into it’s namespace. This is intended for convenient interactive use. matplotlib.pyplot contains the same plotting functions as pylab, but doesn’t pollute the namespace with numpy functions and other stuff.

    For more structured development, you may be better off using the object-oriented core API. Most of the plotting functions in the pylab module map onto the methods of Axes objects.

    Comment by BC — 2009-6-5 @ 4:58 pm

  3. Yes, matplotlib can be very daunting. I’m maintaining a project written by someone who was new to both Python and Matplotlib. He did an amazing job doing some OO wrapping about calls to gcf() and other ugly non-OO stuff. If he had seen the OO interface, we might have some cleaner code. :)

    Axes are the x/y things on which you plot values, graphs are an instance of values plotted on axes, and a figure can contain one or more graphs.

    BTW, if you’re not too heavily invested, take a look at Chaco: http://code.enthought.com/chaco/ Very OO interace, and makes some pretty graphs.

    Comment by Joshua Kugler — 2009-6-5 @ 8:06 pm

  4. matplotlib definetly needs better documentation, but it does work quite nicely once you manage to get around to doing something.

    As for plotting with the OO core API, is there a good tutorial/introduction about that anywhere?

    Comment by Marcus — 2009-6-5 @ 10:58 pm

  5. @Bryan: use it, really. Slowly learning my way around.

    @Joshua: chaco looks interesting, and since I just started with matplotlib, I might switch.

    Comment by Thomas — 2009-6-6 @ 10:51 am

  6. Agreed, its high time we get a better graphing library in linux, imho….

    Comment by Kevin DuBois — 2009-6-8 @ 2:13 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment