From bfab80e4567573dacbde83f89b60142075eca103 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 9 Oct 2015 00:52:34 -0400 Subject: [PATCH 1/3] Fix PathEffect rendering on some backends The special sub-GC that is created by the PathEffectRenderer was of GraphicsContextBase, rather than the backend-specific GC. Fix #5049, Fix #4024 --- lib/matplotlib/patheffects.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/patheffects.py b/lib/matplotlib/patheffects.py index 65b98ae19be5..5435bcc8bd00 100644 --- a/lib/matplotlib/patheffects.py +++ b/lib/matplotlib/patheffects.py @@ -98,6 +98,9 @@ def __init__(self, path_effects, renderer): self._path_effects = path_effects self._renderer = renderer + def new_gc(self): + return self._renderer.new_gc() + def copy_with_path_effect(self, path_effects): return self.__class__(path_effects, self._renderer) From daf7ad5dc188916f03352027dd072fb392981270 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 9 Oct 2015 11:56:35 -0400 Subject: [PATCH 2/3] Add test --- lib/matplotlib/tests/test_backend_ps.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index c01395c96d7f..db124da554b5 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -10,6 +10,7 @@ import matplotlib import matplotlib.pyplot as plt +from matplotlib import patheffects from matplotlib.testing.decorators import cleanup, knownfailureif @@ -120,6 +121,16 @@ def test_composite_image(): assert buff.count(six.b(' colorimage')) == 2 +@cleanup +def test_patheffects(): + with matplotlib.rc_context(): + matplotlib.rcParams['path.effects'] = [patheffects.withStroke(linewidth=4, foreground='w')] + fig, ax = plt.subplots() + ax.plot([1, 2, 3]) + with io.BytesIO() as ps: + fig.savefig(ps, format='ps') + + if __name__ == '__main__': import nose nose.runmodule(argv=['-s', '--with-doctest'], exit=False) From 1f14776101bde1138c2b70aa8f2cd5ee5e856712 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 9 Oct 2015 13:46:58 -0400 Subject: [PATCH 3/3] Fix PEP8 --- lib/matplotlib/tests/test_backend_ps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index db124da554b5..ab346a4d0a41 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -124,7 +124,8 @@ def test_composite_image(): @cleanup def test_patheffects(): with matplotlib.rc_context(): - matplotlib.rcParams['path.effects'] = [patheffects.withStroke(linewidth=4, foreground='w')] + matplotlib.rcParams['path.effects'] = [ + patheffects.withStroke(linewidth=4, foreground='w')] fig, ax = plt.subplots() ax.plot([1, 2, 3]) with io.BytesIO() as ps: