Hi, I'm using matplotlib embedded in my wxpython application and needed to give users a quick way to relimit a figure, for example after removing a line from a plot. Therefore I added a button to the toolbar. Do you think it would make sense to include this in matplotlib by default? Appended you find modifications of backend_bases.py and backends/backend_wx.py as well as a draft for a symbol.
Greetings, Dieter
Index: lib/matplotlib/backend_bases.py
===================================================================
--- lib/matplotlib/backend_bases.py (Revision 8721)
+++ lib/matplotlib/backend_bases.py (Arbeitskopie)
@@ -2388,6 +2388,15 @@
self.set_history_buttons()
self._update_view()
+ def relim(self, *args):
+ 'Fit all objects into view'
+ self.update()
+ for a in self.canvas.figure.get_axes():
+ a.relim()
+ a.autoscale()
+ a.autoscale_view()
+ self.draw()
+
def _init_toolbar(self):
"""
This is where you actually build the GUI widgets (called by
Index: lib/matplotlib/backends/backend_wx.py
===================================================================
--- lib/matplotlib/backends/backend_wx.py (Revision 8721)
+++ lib/matplotlib/backends/backend_wx.py (Arbeitskopie)
@@ -1755,6 +1755,7 @@
self._parent = self.canvas.GetParent()
_NTB2_HOME =wx.NewId()
+ _NTB2_RELIM =wx.NewId()
self._NTB2_BACK =wx.NewId()
self._NTB2_FORWARD =wx.NewId()
self._NTB2_PAN =wx.NewId()
@@ -1766,6 +1767,8 @@
self.AddSimpleTool(_NTB2_HOME, _load_bitmap('home.png'),
'Home', 'Reset original view')
+ self.AddSimpleTool(_NTB2_RELIM, _load_bitmap('relim.png'),
+ 'Relimit', 'Fit all elements into plot')
self.AddSimpleTool(self._NTB2_BACK, _load_bitmap('back.png'),
'Back', 'Back navigation view')
self.AddSimpleTool(self._NTB2_FORWARD, _load_bitmap('forward.png'),
@@ -1785,6 +1788,7 @@
'Save', 'Save plot contents to file')
bind(self, wx.EVT_TOOL, self.home, id=_NTB2_HOME)
+ bind(self, wx.EVT_TOOL, self.relim, id=_NTB2_RELIM)
bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD)
bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK)
bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM)
<<attachment: relim.xpm>>
<<attachment: relim.svg>>
<<attachment: relim.ppm>>
<<attachment: relim.png>>
------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________ Matplotlib-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
