Skip to content

Commit

Permalink
Merge pull request matplotlib#1221 from efiring/revert_1125_oo_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
efiring committed Sep 8, 2012
2 parents 32dc947 + b0807ae commit 8b8d24f
Show file tree
Hide file tree
Showing 27 changed files with 5 additions and 64 deletions.
11 changes: 0 additions & 11 deletions doc/users/whats_new.rst
Expand Up @@ -41,17 +41,6 @@ Features that depend on the Python Imaging Library, such as JPEG
handling, do not work, since the version of PIL for Python 3.x is not
sufficiently mature.

Object-oriented interface
-------------------------

Damon McDougall has reduced some of the boilerplate code needed to interact
with the object-oriented interface. Now a figure canvas is set up by default::

>>> from matplotlib.figure import Figure
>>> fig = Figure()
>>> ax = fig.add_subplot(1, 1, 1)
>>> fig.savefig('figure.pdf')

PGF/TikZ backend
----------------
Peter Würtz wrote a backend that allows matplotlib to export figures as
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_agg.py
Expand Up @@ -515,5 +515,3 @@ def print_to_buffer(self):
(int(renderer.width), int(renderer.height)))
renderer.dpi = original_dpi
return result

FigureCanvas = FigureCanvasAgg
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_cairo.py
Expand Up @@ -512,5 +512,3 @@ def _save (self, fo, format, **kwargs):

ctx.show_page()
surface.finish()

FigureCanvas = FigureCanvasCairo
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_cocoaagg.py
Expand Up @@ -89,7 +89,7 @@ def stop_event_loop(self):
FigureCanvasBase.stop_event_loop_default(self)
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__

FigureCanvas = FigureCanvasCocoaAgg


NibClassBuilder.extractClasses('Matplotlib.nib', mplBundle)

Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_emf.py
Expand Up @@ -727,8 +727,6 @@ def print_emf(self, filename, dpi=300, **kwargs):
def get_default_filetype(self):
return 'emf'

FigureCanvas = FigureCanvasEMF

class FigureManagerEMF(FigureManagerBase):
"""
Wrap everything up into a window for the pylab interface
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_fltkagg.py
Expand Up @@ -231,8 +231,6 @@ def stop_event_loop(self):
FigureCanvasBase.stop_event_loop_default(self)
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__

FigureCanvas = FigureCanvasFltkAgg

def destroy_figure(ptr, figman):
figman.window.hide()
Fltk.Fl.wait(0) # This is needed to make the last figure vanish.
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/backends/backend_gdk.py
Expand Up @@ -434,7 +434,7 @@ def new_figure_manager_given_figure(num, figure):
return manager


class FigureCanvasGDK(FigureCanvasBase):
class FigureCanvasGDK (FigureCanvasBase):
def __init__(self, figure):
FigureCanvasBase.__init__(self, figure)

Expand Down Expand Up @@ -472,5 +472,3 @@ def _print_image(self, filename, format, *args, **kwargs):
0, 0, 0, 0, width, height)

pixbuf.save(filename, format)

FigureCanvas = FigureCanvasGDK
4 changes: 1 addition & 3 deletions lib/matplotlib/backends/backend_gtk.py
Expand Up @@ -144,7 +144,7 @@ def _on_timer(self):
return False


class FigureCanvasGTK(gtk.DrawingArea, FigureCanvasBase):
class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
keyvald = {65507 : 'control',
65505 : 'shift',
65513 : 'alt',
Expand Down Expand Up @@ -519,8 +519,6 @@ def stop_event_loop(self):
FigureCanvasBase.stop_event_loop_default(self)
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__

FigureCanvas = FigureCanvasGTK

class FigureManagerGTK(FigureManagerBase):
"""
Public attributes
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_gtk3.py
Expand Up @@ -98,7 +98,7 @@ def _on_timer(self):
self._timer = None
return False

class FigureCanvasGTK3(Gtk.DrawingArea, FigureCanvasBase):
class FigureCanvasGTK3 (Gtk.DrawingArea, FigureCanvasBase):
keyvald = {65507 : 'control',
65505 : 'shift',
65513 : 'alt',
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_gtk3agg.py
Expand Up @@ -67,7 +67,6 @@ def print_png(self, filename, *args, **kwargs):
agg = self.switch_backends(backend_agg.FigureCanvasAgg)
return agg.print_png(filename, *args, **kwargs)

FigureCanvas = FigureCanvasGTK3Agg

class FigureManagerGTK3Agg(backend_gtk3.FigureManagerGTK3):
pass
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_gtk3cairo.py
Expand Up @@ -34,7 +34,6 @@ def on_draw_event(self, widget, ctx):

return False # finish event propagation?

FigureCanvas = FigureCanvasGTK3Cairo

class FigureManagerGTK3Cairo(backend_gtk3.FigureManagerGTK3):
pass
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_gtkagg.py
Expand Up @@ -111,7 +111,6 @@ def print_png(self, filename, *args, **kwargs):
agg = self.switch_backends(FigureCanvasAgg)
return agg.print_png(filename, *args, **kwargs)

FigureCanvas = FigureCanvasGTKAgg

"""\
Traceback (most recent call last):
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_gtkcairo.py
Expand Up @@ -55,7 +55,6 @@ def _renderer_init(self):
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
self._renderer = RendererGTKCairo (self.figure.dpi)

FigureCanvas = FigureCanvasGTKCairo

class FigureManagerGTKCairo(FigureManagerGTK):
def _get_toolbar(self, canvas):
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_macosx.py
Expand Up @@ -352,7 +352,6 @@ def new_timer(self, *args, **kwargs):
"""
return TimerMac(*args, **kwargs)

FigureCanvas = FigureCanvasMac

class FigureManagerMac(_macosx.FigureManager, FigureManagerBase):
"""
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_pdf.py
Expand Up @@ -2299,8 +2299,6 @@ def print_pdf(self, filename, **kwargs):
else: # we opened the file above; now finish it off
file.close()

FigureCanvas = FigureCanvasPdf

class FigureManagerPdf(FigureManagerBase):
pass

Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_pgf.py
Expand Up @@ -838,8 +838,6 @@ def _render_texts_pgf(self, fh):
def get_renderer(self):
return RendererPgf(self.figure, None)

FigureCanvas = FigureCanvasPgf

class FigureManagerPgf(FigureManagerBase):
def __init__(self, *args):
FigureManagerBase.__init__(self, *args)
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Expand Up @@ -1357,8 +1357,6 @@ def write(self, *kl, **kwargs):
shutil.move(tmpfile, outfile)
os.chmod(outfile, mode)

FigureCanvas = FigureCanvasPS

def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
paperWidth, paperHeight, orientation):
"""
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_qt.py
Expand Up @@ -203,8 +203,6 @@ def stop_event_loop(self):
FigureCanvasBase.stop_event_loop_default(self)
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__

FigureCanvas = FigureCanvasQT

class FigureManagerQT( FigureManagerBase ):
"""
Public attributes
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_qt4.py
Expand Up @@ -377,8 +377,6 @@ def idle_draw(*args):
self._idle = True
if d: QtCore.QTimer.singleShot(0, idle_draw)

FigureCanvas = FigureCanvasQT

class FigureManagerQT( FigureManagerBase ):
"""
Public attributes
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_qt4agg.py
Expand Up @@ -145,5 +145,3 @@ def blit(self, bbox=None):
def print_figure(self, *args, **kwargs):
FigureCanvasAgg.print_figure(self, *args, **kwargs)
self.draw()

FigureCanvas = FigureCanvasQTAgg
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_qtagg.py
Expand Up @@ -156,5 +156,3 @@ def blit(self, bbox=None):
def print_figure(self, *args, **kwargs):
FigureCanvasAgg.print_figure(self, *args, **kwargs)
self.draw()

FigureCanvas = FigureCanvasQTAgg
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_svg.py
Expand Up @@ -1143,8 +1143,6 @@ def _print_svg(self, filename, svgwriter, fh_to_close=None, **kwargs):
def get_default_filetype(self):
return 'svg'

FigureCanvas = FigureCanvasSVG

class FigureManagerSVG(FigureManagerBase):
pass

Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_template.py
Expand Up @@ -245,8 +245,6 @@ def print_foo(self, filename, *args, **kwargs):
def get_default_filetype(self):
return 'foo'

FigureCanvas = FigureCanvasTemplate

class FigureManagerTemplate(FigureManagerBase):
"""
Wrap everything up into a window for the pylab interface
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_tkagg.py
Expand Up @@ -505,8 +505,6 @@ def stop_event_loop(self):
FigureCanvasBase.stop_event_loop_default(self)
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__

FigureCanvas = FigureCanvasTkAgg

class FigureManagerTkAgg(FigureManagerBase):
"""
Public attributes
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_wx.py
Expand Up @@ -1400,7 +1400,6 @@ def _onEnter(self, evt):
"""Mouse has entered the window."""
FigureCanvasBase.enter_notify_event(self, guiEvent = evt)

FigureCanvas = FigureCanvasWx

########################################################################
#
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_wxagg.py
Expand Up @@ -105,8 +105,6 @@ def print_figure(self, filename, *args, **kwargs):
if self._isDrawn:
self.draw()

FigureCanvas = FigureCanvasWxAgg

class NavigationToolbar2WxAgg(NavigationToolbar2Wx):
def get_canvas(self, frame, fig):
return FigureCanvasWxAgg(frame, -1, fig)
Expand Down
10 changes: 1 addition & 9 deletions lib/matplotlib/figure.py
Expand Up @@ -318,7 +318,7 @@ def __init__(self,
self.patch.set_aa(False)

self._hold = rcParams['axes.hold']
self.canvas = self._setup_canvas()
self.canvas = None

if subplotpars is None:
subplotpars = SubplotParams()
Expand All @@ -330,14 +330,6 @@ def __init__(self,
self.clf()
self._cachedRenderer = None

def _setup_canvas(self):
"""
Return the FigureCanvas instance defined by the currently loaded backend.
"""
import matplotlib.backends as mbackends # lazy import
backend_mod = mbackends.pylab_setup()[0]
return backend_mod.FigureCanvas(self)

def show(self, warn=True):
"""
If using a GUI backend with pyplot, display the figure window.
Expand Down

0 comments on commit 8b8d24f

Please sign in to comment.