Skip to content

Commit 884a566

Browse files
committed
added figure show method for pylab convenience
svn path=/trunk/matplotlib/; revision=3380
1 parent 648b117 commit 884a566

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

examples/pick_event_demo2.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ def onpick(event):
3030
ax.plot(X[dataind])
3131
ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
3232
transform=ax.transAxes, va='top')
33-
ax.set_ylim(-0.5, 1.5)
34-
ax.figure.canvas.draw()
35-
36-
show() # oops, we need a way to raise figures created in callbacks
33+
ax.set_ylim(-0.5, 1.5)
34+
figi.show()
3735
return True
3836

3937
fig.canvas.mpl_connect('pick_event', onpick)

lib/matplotlib/backends/backend_gtk.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ def __init__(self, canvas, num):
450450
self.vbox.show()
451451

452452
self.canvas.show()
453+
454+
# attach a show method to the figure for pylab ease of use
455+
self.canvas.figure.show = lambda *args: self.window.show()
456+
453457
self.vbox.pack_start(self.canvas, True, True)
454458

455459
self.toolbar = self._get_toolbar(canvas)

lib/matplotlib/backends/backend_qt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ def __init__( self, canvas, num ):
212212
if matplotlib.is_interactive():
213213
self.window.show()
214214

215+
# attach a show method to the figure for pylab ease of use
216+
self.canvas.figure.show = lambda *args: self.window.show()
217+
215218
def notify_axes_change( fig ):
216219
# This will be called whenever the current axes is changed
217220
if self.toolbar != None: self.toolbar.update()

lib/matplotlib/backends/backend_qt4.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ def __init__( self, canvas, num ):
216216
if matplotlib.is_interactive():
217217
self.window.show()
218218

219+
# attach a show method to the figure for pylab ease of use
220+
self.canvas.figure.show = lambda *args: self.window.show()
221+
219222
def notify_axes_change( fig ):
220223
# This will be called whenever the current axes is changed
221224
if self.toolbar != None: self.toolbar.update()

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ def notify_axes_change(fig):
324324
self.canvas.figure.add_axobserver(notify_axes_change)
325325

326326

327+
328+
# attach a show method to the figure for pylab ease of use
329+
self.canvas.figure.show = lambda *args: self.show()
330+
331+
327332
def resize(self, event):
328333
width, height = event.width, event.height
329334
self.toolbar.configure(width=width) # , height=height)

lib/matplotlib/backends/backend_wx.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,15 @@ def notify_axes_change(fig):
13851385
if self.tb != None: self.tb.update()
13861386
self.canvas.figure.add_axobserver(notify_axes_change)
13871387

1388+
def showfig(*args):
1389+
figwin.frame.Show()
1390+
figwin.canvas.realize()
1391+
figwin.canvas.draw()
1392+
1393+
# attach a show method to the figure
1394+
self.canvas.figure.show = showfig
1395+
1396+
13881397
def destroy(self, *args):
13891398
DEBUG_MSG("destroy()", 1, self)
13901399
self.frame.Destroy()

0 commit comments

Comments
 (0)