I'm trying to generate plots as textures for use within a real-time graphics application (written using the pythonOgre graphics engine). I'm brand new to matplotlib so please bear with me. Two questions, one easy, one possibly hard.
In the following code snippet, I create and draw a pie chart, do some intermediate work, update the pie fractions, and redraw. I end up with the second version superimposed on the first. Initially I thought it was simply a matter of clearing the canvas, but as I repeat this test with more and more updates, the redraw seems to slow down - this makes me think that each redraw is actually rerendering all the layers. Is this the case? If so, how do I avoid it? # create matplotlib figure figure = Figure(figsize=(4,3), dpi=200, frameon=True) figureCanvas = FigureCanvas(figure) # unchanging details of pie chart ax = figure.add_subplot(111) # pie plot labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' ax.set_title('Example pyOgre Pie Chart') ax.grid(True) ax.pie([25,25,30,20], labels=labels) figureCanvas.draw() # .... # update pie chart ax.pie([30,25,25,20], labels=labels) # matplotlib draw figureCanvas.draw() And the harder question. I need access to the address of the raw image buffer. (I assume this is a contiguous block of c-allocated memory?) Presently, I copy into a ctypes buffer but this slows things down significantly. Is there an alternative approach? # retrieve buffer from matplotlib height = int( figureCanvas.get_renderer().height ) width = int( figureCanvas.get_renderer().width ) # extract image buffer (need as void ptr to contiguous byte array) buff = figureCanvas.buffer_rgba(0,0) cbuffer[:] = buff[:] ## would prefer to eliminate this step address = ctypes.addressof(cbuffer) Any help is much appreciated ... Cheers, Darran. -- Darran Edmundson [EMAIL PROTECTED] http://www.edmstudio.com ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users