Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7223c8

Browse files
committed
Various backend cleanups.
- Noninteractive backends don't need to redefine `draw()` as a do-nothing: that's already the default in the base class. - The pgf backend manager can just be an alias for FigureManagerBase: this is consistent with the other noninteractive backends. - FigureCanvasQT doesn't need to assign `self.figure = figure`: that's already done in the super() init. - Use star-unpack in backend_template. - The list of event handlers set up by backend_wx is much bigger than previously documented.
1 parent 84e531b commit a7223c8

File tree

7 files changed

+6
-21
lines changed

7 files changed

+6
-21
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ class FigureCanvasAgg(FigureCanvasBase):
373373
----------
374374
figure : `matplotlib.figure.Figure`
375375
A high-level Figure instance
376-
377376
"""
378377

379378
def copy_from_bbox(self, bbox):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,14 +2518,9 @@ class FigureCanvasPdf(FigureCanvasBase):
25182518
----------
25192519
figure : `matplotlib.figure.Figure`
25202520
A high-level Figure instance
2521-
25222521
"""
25232522

25242523
fixed_dpi = 72
2525-
2526-
def draw(self):
2527-
pass
2528-
25292524
filetypes = {'pdf': 'Portable Document Format'}
25302525

25312526
def get_default_filetype(self):

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,14 +963,12 @@ def get_renderer(self):
963963
return RendererPgf(self.figure, None, dummy=True)
964964

965965

966-
class FigureManagerPgf(FigureManagerBase):
967-
pass
966+
FigureManagerPgf = FigureManagerBase
968967

969968

970969
@_Backend.export
971970
class _BackendPgf(_Backend):
972971
FigureCanvas = FigureCanvasPgf
973-
FigureManager = FigureManagerPgf
974972

975973

976974
def _cleanup_all():

lib/matplotlib/backends/backend_ps.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,6 @@ def swap_if_landscape(self, shape):
815815

816816
class FigureCanvasPS(FigureCanvasBase):
817817
fixed_dpi = 72
818-
819-
def draw(self):
820-
pass
821-
822818
filetypes = {'ps': 'Postscript',
823819
'eps': 'Encapsulated Postscript'}
824820

lib/matplotlib/backends/backend_qt5.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ def __init__(self, figure):
230230
_create_qApp()
231231
super().__init__(figure=figure)
232232

233-
self.figure = figure
234233
# We don't want to scale up the figure DPI more than once.
235234
# Note, we don't handle a signal for changing DPI yet.
236235
figure._original_dpi = figure.dpi

lib/matplotlib/backends/backend_template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ def draw(self):
200200

201201
# If the file type is not in the base set of filetypes,
202202
# you should add it to the class-scope filetypes dictionary as follows:
203-
filetypes = FigureCanvasBase.filetypes.copy()
204-
filetypes['foo'] = 'My magic Foo format'
203+
filetypes = {**FigureCanvasBase.filetypes, 'foo': 'My magic Foo format'}
205204

206205
def print_foo(self, filename, *args, **kwargs):
207206
"""

lib/matplotlib/backends/backend_wx.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,11 @@ class _FigureCanvasWxBase(FigureCanvasBase, wx.Panel):
581581

582582
def __init__(self, parent, id, figure):
583583
"""
584-
Initialise a FigureWx instance.
584+
Initialize a FigureWx instance.
585585
586-
- Initialise the FigureCanvasBase and wxPanel parents.
587-
- Set event handlers for:
588-
EVT_SIZE (Resize event)
589-
EVT_PAINT (Paint event)
586+
- Initialize the FigureCanvasBase and wxPanel parents.
587+
- Set event handlers for resize, paint, and keyboard and mouse
588+
interaction.
590589
"""
591590

592591
FigureCanvasBase.__init__(self, figure)

0 commit comments

Comments
 (0)