From: John H. <jdh...@ac...> - 2005-11-30 21:21:23
|
>>>>> "massimo" == massimo sandal <mas...@un...> writes: massimo> About the OO MPL interface, it seems to be a bit lacking massimo> in documentation. Is there some hint you can give me? There is some tutorial documentation, particularly Robert Leftwich's tutorial - http://matplotlib.sourceforge.net/leftwich_tut.txt. This link recently disappeared (by accident) from the FAQ entry http://matplotlib.sf.net/faq.html#OO massimo> What important goodies pylab has that the OO interface massimo> has not? I'm expecially concerned about the rectangular massimo> zoom and mapping the mouse position on the plot, I have massimo> quite a need for them. I would humbly suggest that the difficulty of the OO interface is overstated. There is almost nothing in the pylab interface -- all of it is a wrapper of the OO code. With the exception of figure management, of course, which you don't want to use in an app anyway. Consider the canonical OO example from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure fig = Figure() canvas = FigureCanvas(fig) ax = fig.add_subplot(111) ax.plot([1,2,3]) ax.set_title('hi mom') ax.grid(True) ax.set_xlabel('time') ax.set_ylabel('volts') canvas.print_figure('test') As for interaction, you can do all the panning, zooming, toolbaring, whatevering you want from the OO interface. Just connect to the events you want with canvas.mpl_connect if you want to use matplotlib's event handling, and you can use ax.pick if you want to pick actors. For examples on using events, search the examples dir for "connect" > grep -l "connect(" *.py | xargs ls animation_blit_fltk.py embedding_in_qt.py picker_demo.py coords_demo.py gtk_spreadsheet.py poly_editor.py cursor_demo.py interactive2.py pylab_with_gtk.py embedding_in_gtk2.py keypress_demo.py strip_chart_demo.py embedding_in_gtk3.py mpl_with_glade.py toggle_images.py embedding_in_gtk.py object_picker.py wxcursor_demo.py As you can see there are a couple of wx specific examples. One nice thing about using mpl event handling instead of native wx handling is that the examples will work unchanged across GUIs, so you can plug these examples directly into your wx app. Just use "canvas.mpl_connect" instead of the pylab "connect" JDH |