Seperate plot rendering implementation from plotting data generation

Registered by Karel Kolman

Make it easier to replace/plug plotting libraries. The currently used wx.lib.plot doesn't produce visually appealing plots (at least the latest trunk version has antialiasing), we should make it easier to plug different rendering libraries. I'm adapting the cairoplot library rendering backend, the graphs it produces look quite attractive.

Blueprint information

Needs approval
Series goal:
Milestone target:
milestone icon 0.7
Started by
Michael Rooney
Completed by
Michael Rooney



2009.12.29 kolmis:
 confirming correct fallback-to-wx behavior on windows.

2009.12.29 mrooney:
Sorry, I meant cairo there and not chaco. I want to make sure that if a Windows user has numpy installed but not GTK, that it falls back to the wx plot instead of dying on cairo dependencies.

2009.12.29 kolmis:
I'm not exactly sure what you mean by the chaco ImportError raising. Running on windows, both 'cairo' and 'wx' suggest the 'python-numpy' package installed for plorrint features.

Shouldn't BasePlotImportException and PlotLibraryImportException be merged into one exception since they're essentially the same ? For example the cairopanel prints a 'python-numpy missing message, but it should be up to baseplot to say what library it misses, not the cairopanel class.

2009.12.29 mrooney:
I removed the chaco support for now, and after testing the fallbacks (except on Windows, I'd like to test that it properly raises an ImportError there for chaco and falls back. If you get a chance to test on Windows before I do, feel free to let me know), I'm calling this Implemented! Thanks again for your excellent contribution.

2009.12.19 kolmis:
yep, the bundled version is the patched one. the tests and test scripts can be deleted.

2009.12.18 mrooney:
Okay, bundling it makes sense then and sounds easy. It is only ~115K or so I see, and the refactoring allowed us to drop bundling which was 85K, so it more or less paid for itself. Is the bundled cairoplot your sped up version? I think the only left to do on this blueprint is get the chaco plot working as well as the others (or just drop it, it may not be valuable to support three different plotting backends, cairoplot seems pretty sufficient). Am I missing anything? Thanks again for your work, the new cairoplot is much better!

2009.12.18 kolmis:
no, cairplot doesn't have a package, moreover its code is very slow, showing a plot in wxbanker took a long time, i had done some tweaks, and proposed a merge
but without a response, i'd bundle it with wxbanker for start...

2009.12.18 mrooney: I thought it might be fun to play around with this tonight, so I merged your branch into trunk and pushed it up to ~mrooney/wxbanker/cairoplot. This is pretty cool stuff, thanks! It was rendering an x_label for each transaction, so I fixed it to do a max of 10, made it handle 0/few transactions better, and also used the same "Granularity" logic of the wxplot since I personally think it looks better/simpler smoothed out that way. I'm going to work on formatting the y labels properly now, and playing around with the appearance. Feel free to branch my branch and continue any progress, and let me know your thoughts on the changes I've made. I assume also bundling cairoplot was just to make it easy to test, and for an actual release we'd just recommend that library and not ship it? I think perhaps I'll make this the default renderer if available for 0.7.

EDIT: Okay, I actually pushed this up to trunk after some modifications. It now will choose cairo by default if it exists, and can fall all the way back to no summary tab. I added the trend line, and make the y labels formatted as currency. Now I see that I guess cairo plot doesn't have a debian package, so it just has to be included? Also, since I factored out the polyfit logic into the baseplot class, wxBanker doesn't need to carry its own file, so I was able to drop that which is very nice.

2009.10.17 kolmis: strange i didn't stumble upon chaco when comparing python plotting libraries, it looks cool, though it does not seem lightweight. i added a basic chaco support to my cairoplot branch, try --debug to have a look. the python-chaco lib in karmic is kind of broken, a quick workaround fix is to patch /usr/lib/python2.6/dist-packages/enthought/kiva/agg/ like this:

#def move_to(*args): return _agg.GraphicsContextArray_move_to(*args)
def move_to(*args): return _agg.GraphicsContextArray_move_to(args[0], float(args[1]), float(args[2]))

2009.10.16 mrooney: Excellent, that sounds like a great idea! I had also looked at Chaco ( and specifically the zooming plot, but never did any more than look at it. I like the idea of making them pluggable, I imagine we might want to make the cairoplot the default but still be able to fall back on where cairoplot isn't installed, say on Windows/OSX, but recommend the dependency in the .deb so anyone on Ubuntu gets it.


Work Items

This blueprint contains Public information 
Everyone can see this information.