22 unicode_literals )
33
44import six
5- from collections import OrderedDict , namedtuple
65
6+ from collections import OrderedDict , namedtuple
7+ from functools import wraps
8+ import inspect
79import re
810import warnings
9- import inspect
11+
1012import numpy as np
13+
1114import matplotlib
12- import matplotlib .cbook as cbook
13- from matplotlib .cbook import mplDeprecation
14- from matplotlib import docstring , rcParams
15- from .transforms import (Bbox , IdentityTransform , TransformedBbox ,
16- TransformedPatchPath , TransformedPath , Transform )
15+ from . import cbook , docstring , rcParams
1716from .path import Path
18- from functools import wraps
19- from contextlib import contextmanager
17+ from . transforms import ( Bbox , IdentityTransform , Transform , TransformedBbox ,
18+ TransformedPatchPath , TransformedPath )
2019# Note, matplotlib artists use the doc strings for set and get
2120# methods to enable the introspection methods of setp and getp. Every
2221# set_* method should have a docstring containing the line
@@ -43,30 +42,23 @@ def allow_rasterization(draw):
4342 other setup function calls, such as starting and flushing a mixed-mode
4443 renderer.
4544 """
46- @contextmanager
47- def with_rasterized (artist , renderer ):
48-
49- if artist .get_rasterized ():
50- renderer .start_rasterizing ()
51-
52- if artist .get_agg_filter () is not None :
53- renderer .start_filter ()
5445
46+ # the axes class has a second argument inframe for its draw method.
47+ @wraps (draw )
48+ def draw_wrapper (artist , renderer , * args , ** kwargs ):
5549 try :
56- yield
50+ if artist .get_rasterized ():
51+ renderer .start_rasterizing ()
52+ if artist .get_agg_filter () is not None :
53+ renderer .start_filter ()
54+
55+ return draw (artist , renderer , * args , ** kwargs )
5756 finally :
5857 if artist .get_agg_filter () is not None :
5958 renderer .stop_filter (artist .get_agg_filter ())
60-
6159 if artist .get_rasterized ():
6260 renderer .stop_rasterizing ()
6361
64- # the axes class has a second argument inframe for its draw method.
65- @wraps (draw )
66- def draw_wrapper (artist , renderer , * args , ** kwargs ):
67- with with_rasterized (artist , renderer ):
68- return draw (artist , renderer , * args , ** kwargs )
69-
7062 draw_wrapper ._supports_rasterization = True
7163 return draw_wrapper
7264
@@ -207,32 +199,6 @@ def convert_yunits(self, y):
207199 return y
208200 return ax .yaxis .convert_units (y )
209201
210- def set_axes (self , axes ):
211- """
212- Set the :class:`~matplotlib.axes.Axes` instance in which the
213- artist resides, if any.
214-
215- This has been deprecated in mpl 1.5, please use the
216- axes property. Will be removed in 1.7 or 2.0.
217-
218- ACCEPTS: an :class:`~matplotlib.axes.Axes` instance
219- """
220- warnings .warn (_get_axes_msg .format ('set_axes' ), mplDeprecation ,
221- stacklevel = 1 )
222- self .axes = axes
223-
224- def get_axes (self ):
225- """
226- Return the :class:`~matplotlib.axes.Axes` instance the artist
227- resides in, or *None*.
228-
229- This has been deprecated in mpl 1.5, please use the
230- axes property. Will be removed in 1.7 or 2.0.
231- """
232- warnings .warn (_get_axes_msg .format ('get_axes' ), mplDeprecation ,
233- stacklevel = 1 )
234- return self .axes
235-
236202 @property
237203 def axes (self ):
238204 """
@@ -243,18 +209,14 @@ def axes(self):
243209
244210 @axes .setter
245211 def axes (self , new_axes ):
246-
247- if (new_axes is not None and
248- (self ._axes is not None and new_axes != self ._axes )):
249- raise ValueError ("Can not reset the axes. You are "
250- "probably trying to re-use an artist "
251- "in more than one Axes which is not "
252- "supported" )
253-
212+ if (new_axes is not None and self ._axes is not None
213+ and new_axes != self ._axes ):
214+ raise ValueError ("Can not reset the axes. You are probably "
215+ "trying to re-use an artist in more than one "
216+ "Axes which is not supported" )
254217 self ._axes = new_axes
255218 if new_axes is not None and new_axes is not self :
256219 self .stale_callback = _stale_axes_callback
257-
258220 return new_axes
259221
260222 @property
0 commit comments