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

Skip to content

Various backend cleanups. #15211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2498,14 +2498,9 @@ class FigureCanvasPdf(FigureCanvasBase):
----------
figure : `matplotlib.figure.Figure`
A high-level Figure instance

"""

fixed_dpi = 72

def draw(self):
pass

filetypes = {'pdf': 'Portable Document Format'}

def get_default_filetype(self):
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,14 +952,12 @@ def get_renderer(self):
return RendererPgf(self.figure, None, dummy=True)


class FigureManagerPgf(FigureManagerBase):
pass
FigureManagerPgf = FigureManagerBase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't do this because you don't create a FigureManagerPgf type with that, so that

>>> mgr = FigureManagerPgf()
>>> type(mgr)
<class 'FigureManagerBase'>

which is a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is consistent with FigureManagerPS, FigureManagerPDF and FigureManagerSVG, and was discussed in #9551 (review).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not convinced this is a good approach, but accepting as precedenced.



@_Backend.export
class _BackendPgf(_Backend):
FigureCanvas = FigureCanvasPgf
FigureManager = FigureManagerPgf


def _cleanup_all():
Expand Down
4 changes: 0 additions & 4 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,6 @@ def swap_if_landscape(self, shape):

class FigureCanvasPS(FigureCanvasBase):
fixed_dpi = 72

def draw(self):
pass

filetypes = {'ps': 'Postscript',
'eps': 'Encapsulated Postscript'}

Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def __init__(self, figure):
_create_qApp()
super().__init__(figure=figure)

self.figure = figure
# We don't want to scale up the figure DPI more than once.
# Note, we don't handle a signal for changing DPI yet.
figure._original_dpi = figure.dpi
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/backend_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ def draw(self):

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

def print_foo(self, filename, *args, **kwargs):
"""
Expand Down
9 changes: 4 additions & 5 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,11 @@ class _FigureCanvasWxBase(FigureCanvasBase, wx.Panel):

def __init__(self, parent, id, figure):
"""
Initialise a FigureWx instance.
Initialize a FigureWx instance.

- Initialise the FigureCanvasBase and wxPanel parents.
- Set event handlers for:
EVT_SIZE (Resize event)
EVT_PAINT (Paint event)
- Initialize the FigureCanvasBase and wxPanel parents.
- Set event handlers for resize, paint, and keyboard and mouse
interaction.
"""

FigureCanvasBase.__init__(self, figure)
Expand Down