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

Skip to content

Commit 31a6682

Browse files
committed
Deprecate support for 3rd-party backends without set_hatch_color.
Inheriting from GraphicsContextBase to get a stub definition of set_hatch_color (or providing your own stub) is really not that much to ask, I believe.
1 parent 38476fd commit 31a6682

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Deprecations
2+
------------
3+
4+
Support for custom backends that do not provide a ``set_hatch_color`` method is
5+
deprecated. We suggest that custom backends let their ``GraphicsContext``
6+
class inherit from `GraphicsContextBase`, to at least provide stubs for all
7+
required methods.

lib/matplotlib/collections.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ def draw(self, renderer):
271271
gc.set_hatch_color(self._hatch_color)
272272
except AttributeError:
273273
# if we end up with a GC that does not have this method
274-
warnings.warn("Your backend does not support setting the "
275-
"hatch color.")
274+
cbook.warn_deprecated(
275+
"3.1", "Your backend does not support setting the hatch "
276+
"color; such backends will become unsupported in "
277+
"Matplotlib 3.3.")
276278

277279
if self.get_sketch_params() is not None:
278280
gc.set_sketch_params(*self.get_sketch_params())

lib/matplotlib/patches.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,10 @@ def draw(self, renderer):
515515
gc.set_hatch_color(self._hatch_color)
516516
except AttributeError:
517517
# if we end up with a GC that does not have this method
518-
warnings.warn(
519-
"Your backend does not support setting the hatch color.")
518+
cbook.warn_deprecated(
519+
"3.1", "Your backend does not support setting the hatch "
520+
"color; such backends will become unsupported in "
521+
"Matplotlib 3.3.")
520522

521523
if self.get_sketch_params() is not None:
522524
gc.set_sketch_params(*self.get_sketch_params())
@@ -4285,8 +4287,10 @@ def draw(self, renderer):
42854287
gc.set_hatch_color(self._hatch_color)
42864288
except AttributeError:
42874289
# if we end up with a GC that does not have this method
4288-
warnings.warn("Your backend does not support setting the "
4289-
"hatch color.")
4290+
cbook.warn_deprecated(
4291+
"3.1", "Your backend does not support setting the "
4292+
"hatch color; such backends will become unsupported "
4293+
"in Matplotlib 3.3.")
42904294

42914295
if self.get_sketch_params() is not None:
42924296
gc.set_sketch_params(*self.get_sketch_params())

0 commit comments

Comments
 (0)