From: Barry Wark <barrywark@gm...> - 2006-12-09 06:36:35
In the process of creating a Cocoa app for scientific data
acquisition, I've built an NSImageView subclass that displays an MPL
figure in the Cocoa NSView hierarchy. It's based on the CocoaAgg
backend code in MPL. There are also some subclasses that allow the use
of Cocoa Bindings to supply the data, axis labels, and units for the
figure. Finally, I've created an IB palette for adding one of the
PlotView subclasses to a Cocoa app and setting its bindings in
For plotting data passed via NSData instances is converted to a numpy
array via numpy.frombuffer using the PlotView's .dtype parameter as
the array dtype (see the source for DataPlotView in PlotView.py).
I think the ability to have such a powerful plotting library available
from Cocoa with so few lines of code illustrates the huge power of the
combination of Cocoa, PyObjC, and the many good Python libraries such
CocoaMPLPlotView requires PyObjc, numpy, and matplotlib.
You can download a copy of the CocoaMPLPlotView and
CocoaMPLPlotViewPalette source from
I don't have time to provide support for these, but would love to hear
if anyone finds them useful. Obviously if you have comments, bugs, or
patches, I'd love to hear those as well. Happy coding.