I’m using matplotlib housed in a wxPython panel to do some heavy duty plotting. My issues comes when using native panning tool – it’s appears as though matplotlib tries to constantly redraw the canvas as you drag the pan handle around. With the amount of data I’m plotting this is getting really choppy (already optimized with Collections for data etc)
In terms of performance I think it would be much preferable for the canvas to just draw once when the mouse is released at the end of a pan. I realise this will mean I have to extend the WxAgg NavigationToolbar2 class with my own, but I’m wondering if anyone has attempted something similar to this and can advise me on which functions to override?
many thanks
I’ve spent a lot of time making modification on the matplotlib backends, I’ve never done this specific change, but I can show you one line of code to comment out that will stop the dynamic updating:
I presume you are using the
WxAggbackend, if this is the case, open this file:C:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.pyAnd comment out the line indicated here:
I tested this and it seems to nicely solve your issue. I did some quick digging and I didn’t see any other functions calling this procedure so you might even be able to just change it to:
…Which is the same code you’ll find in the base
NavigationToolbar2class(And of course, if you’re happy with this change you can do a little more work to make your own custom backend with this kind of modification. Just to make sure you don’t lose the change when upgrading matplotlib)