Skip to content

pgf backend cleanups. #15977

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
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,9 @@ an internal helper).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This method is deprecated. If needed, directly assign to the ``params``
attribute of the Substitution object.

PGF backend cleanups
~~~~~~~~~~~~~~~~~~~~
The *dummy* parameter of `.RendererPgf` is deprecated.

`.GraphicsContextPgf` is deprecated (use `.GraphicsContextBase` instead).
22 changes: 8 additions & 14 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def _get_image_inclusion_command():

class RendererPgf(RendererBase):

@cbook._delete_parameter("3.3", "dummy")
def __init__(self, figure, fh, dummy=False):
"""
Creates a new PGF renderer that translates any drawing instruction
Expand All @@ -412,13 +413,6 @@ def __init__(self, figure, fh, dummy=False):
for m in RendererPgf.__dict__:
if m.startswith("draw_"):
self.__dict__[m] = lambda *args, **kwargs: None
else:
# if fh does not belong to a filename, deactivate draw_image
if not hasattr(fh, 'name') or not os.path.exists(fh.name):
self.__dict__["draw_image"] = \
lambda *args, **kwargs: cbook._warn_external(
"streamed pgf-code does not support raster graphics, "
"consider using the pgf-to-pdf option")

@cbook.deprecated("3.2")
@property
Expand Down Expand Up @@ -646,6 +640,11 @@ def draw_image(self, gc, x, y, im, transform=None):
if w == 0 or h == 0:
return

if not os.path.exists(getattr(self.fh, "name", "")):
cbook._warn_external(
"streamed pgf-code does not support raster graphics, consider "
"using the pgf-to-pdf option.")

# save the images to png files
path = pathlib.Path(self.fh.name)
fname_img = "%s-img%d.png" % (path.stem, self.image_counter)
Expand Down Expand Up @@ -756,16 +755,11 @@ def points_to_pixels(self, points):
# docstring inherited
return points * mpl_pt_to_in * self.dpi

def new_gc(self):
# docstring inherited
return GraphicsContextPgf()


@cbook.deprecated("3.3", alternative="GraphicsContextBase")
class GraphicsContextPgf(GraphicsContextBase):
pass

########################################################################


class TmpDirCleaner:
remaining_tmpdirs = set()
Expand Down Expand Up @@ -949,7 +943,7 @@ def print_png(self, fname_or_fh, *args, **kwargs):
self._print_png_to_fh(file, *args, **kwargs)

def get_renderer(self):
return RendererPgf(self.figure, None, dummy=True)
return RendererPgf(self.figure, None)


class FigureManagerPgf(FigureManagerBase):
Expand Down