Permalink
Browse files

added figure show method for pylab convenience

svn path=/trunk/matplotlib/; revision=3380
  • Loading branch information...
1 parent 648b117 commit 884a5665367e24c52ce3d2635304926af02667ff @jdh2358 jdh2358 committed Jun 8, 2007
@@ -30,10 +30,8 @@ def onpick(event):
ax.plot(X[dataind])
ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
transform=ax.transAxes, va='top')
- ax.set_ylim(-0.5, 1.5)
- ax.figure.canvas.draw()
-
- show() # oops, we need a way to raise figures created in callbacks
+ ax.set_ylim(-0.5, 1.5)
+ figi.show()
return True
fig.canvas.mpl_connect('pick_event', onpick)
@@ -450,6 +450,10 @@ def __init__(self, canvas, num):
self.vbox.show()
self.canvas.show()
+
+ # attach a show method to the figure for pylab ease of use
+ self.canvas.figure.show = lambda *args: self.window.show()
+
self.vbox.pack_start(self.canvas, True, True)
self.toolbar = self._get_toolbar(canvas)
@@ -212,6 +212,9 @@ def __init__( self, canvas, num ):
if matplotlib.is_interactive():
self.window.show()
+ # attach a show method to the figure for pylab ease of use
+ self.canvas.figure.show = lambda *args: self.window.show()
+
def notify_axes_change( fig ):
# This will be called whenever the current axes is changed
if self.toolbar != None: self.toolbar.update()
@@ -216,6 +216,9 @@ def __init__( self, canvas, num ):
if matplotlib.is_interactive():
self.window.show()
+ # attach a show method to the figure for pylab ease of use
+ self.canvas.figure.show = lambda *args: self.window.show()
+
def notify_axes_change( fig ):
# This will be called whenever the current axes is changed
if self.toolbar != None: self.toolbar.update()
@@ -324,6 +324,11 @@ def notify_axes_change(fig):
self.canvas.figure.add_axobserver(notify_axes_change)
+
+ # attach a show method to the figure for pylab ease of use
+ self.canvas.figure.show = lambda *args: self.show()
+
+
def resize(self, event):
width, height = event.width, event.height
self.toolbar.configure(width=width) # , height=height)
@@ -1385,6 +1385,15 @@ def notify_axes_change(fig):
if self.tb != None: self.tb.update()
self.canvas.figure.add_axobserver(notify_axes_change)
+ def showfig(*args):
+ figwin.frame.Show()
+ figwin.canvas.realize()
+ figwin.canvas.draw()
+
+ # attach a show method to the figure
+ self.canvas.figure.show = showfig
+
+
def destroy(self, *args):
DEBUG_MSG("destroy()", 1, self)
self.frame.Destroy()

0 comments on commit 884a566

Please sign in to comment.