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

Skip to content

Commit d0922df

Browse files
authored
Merge pull request #9128 from anntzer/remove-getset-axes
Remove Artist.{get,set}_axes.
2 parents 947a56c + f7ec3b1 commit d0922df

File tree

5 files changed

+36
-87
lines changed

5 files changed

+36
-87
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Removal of deprecated methods
2+
`````````````````````````````
3+
The deprecated `Artist.get_axes` and `Artist.set_axes` methods have been
4+
removed

doc/api/artist_api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ Figure and Axes
126126
Artist.remove
127127

128128
Artist.axes
129-
Artist.get_axes
130-
Artist.set_axes
131129

132130
Artist.set_figure
133131
Artist.get_figure

doc/api/axes_api.rst

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -581,44 +581,41 @@ General Artist Properties
581581
:template: autosummary.rst
582582
:nosignatures:
583583

584+
Axes.set_agg_filter
584585
Axes.set_alpha
585586
Axes.set_animated
586587
Axes.set_clip_box
587588
Axes.set_clip_on
588589
Axes.set_clip_path
589590
Axes.set_gid
590591
Axes.set_label
591-
Axes.set_url
592-
Axes.set_visible
593-
Axes.set_zorder
592+
Axes.set_path_effects
594593
Axes.set_rasterized
595594
Axes.set_sketch_params
596-
Axes.set_agg_filter
597595
Axes.set_snap
598596
Axes.set_transform
599-
Axes.set_path_effects
597+
Axes.set_url
598+
Axes.set_visible
599+
Axes.set_zorder
600600

601601
Axes.get_agg_filter
602-
Axes.get_sketch_params
603602
Axes.get_alpha
604603
Axes.get_animated
605604
Axes.get_clip_box
606605
Axes.get_clip_on
607606
Axes.get_clip_path
608607
Axes.get_gid
609608
Axes.get_label
609+
Axes.get_path_effects
610+
Axes.get_rasterized
611+
Axes.get_sketch_params
612+
Axes.get_snap
613+
Axes.get_transform
610614
Axes.get_url
611615
Axes.get_visible
612616
Axes.get_zorder
613-
Axes.get_rasterized
614-
Axes.get_transform
615-
Axes.get_snap
616-
Axes.get_path_effects
617-
618617

619618
Axes.axes
620-
Axes.get_axes
621-
Axes.set_axes
622619
Axes.set_figure
623620
Axes.get_figure
624621

doc/api/axis_api.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ Ticks
481481
Tick.get_agg_filter
482482
Tick.get_alpha
483483
Tick.get_animated
484-
Tick.get_axes
485484
Tick.get_children
486485
Tick.get_clip_box
487486
Tick.get_clip_on
@@ -517,7 +516,6 @@ Ticks
517516
Tick.set_agg_filter
518517
Tick.set_alpha
519518
Tick.set_animated
520-
Tick.set_axes
521519
Tick.set_clip_box
522520
Tick.set_clip_on
523521
Tick.set_clip_path
@@ -551,7 +549,6 @@ Ticks
551549
XTick.get_agg_filter
552550
XTick.get_alpha
553551
XTick.get_animated
554-
XTick.get_axes
555552
XTick.get_children
556553
XTick.get_clip_box
557554
XTick.get_clip_on
@@ -587,7 +584,6 @@ Ticks
587584
XTick.set_agg_filter
588585
XTick.set_alpha
589586
XTick.set_animated
590-
XTick.set_axes
591587
XTick.set_clip_box
592588
XTick.set_clip_on
593589
XTick.set_clip_path
@@ -621,7 +617,6 @@ Ticks
621617
YTick.get_agg_filter
622618
YTick.get_alpha
623619
YTick.get_animated
624-
YTick.get_axes
625620
YTick.get_children
626621
YTick.get_clip_box
627622
YTick.get_clip_on
@@ -657,7 +652,6 @@ Ticks
657652
YTick.set_agg_filter
658653
YTick.set_alpha
659654
YTick.set_animated
660-
YTick.set_axes
661655
YTick.set_clip_box
662656
YTick.set_clip_on
663657
YTick.set_clip_path
@@ -701,7 +695,6 @@ Axis
701695
Axis.get_agg_filter
702696
Axis.get_alpha
703697
Axis.get_animated
704-
Axis.get_axes
705698
Axis.get_children
706699
Axis.get_clip_box
707700
Axis.get_clip_on
@@ -737,7 +730,6 @@ Axis
737730
Axis.set_agg_filter
738731
Axis.set_alpha
739732
Axis.set_animated
740-
Axis.set_axes
741733
Axis.set_clip_box
742734
Axis.set_clip_on
743735
Axis.set_clip_path
@@ -771,7 +763,6 @@ Axis
771763
XAxis.get_agg_filter
772764
XAxis.get_alpha
773765
XAxis.get_animated
774-
XAxis.get_axes
775766
XAxis.get_children
776767
XAxis.get_clip_box
777768
XAxis.get_clip_on
@@ -807,7 +798,6 @@ Axis
807798
XAxis.set_agg_filter
808799
XAxis.set_alpha
809800
XAxis.set_animated
810-
XAxis.set_axes
811801
XAxis.set_clip_box
812802
XAxis.set_clip_on
813803
XAxis.set_clip_path
@@ -841,7 +831,6 @@ Axis
841831
YAxis.get_agg_filter
842832
YAxis.get_alpha
843833
YAxis.get_animated
844-
YAxis.get_axes
845834
YAxis.get_children
846835
YAxis.get_clip_box
847836
YAxis.get_clip_on
@@ -877,7 +866,6 @@ Axis
877866
YAxis.set_agg_filter
878867
YAxis.set_alpha
879868
YAxis.set_animated
880-
YAxis.set_axes
881869
YAxis.set_clip_box
882870
YAxis.set_clip_on
883871
YAxis.set_clip_path

lib/matplotlib/artist.py

Lines changed: 22 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22
unicode_literals)
33

44
import six
5-
from collections import OrderedDict, namedtuple
65

6+
from collections import OrderedDict, namedtuple
7+
from functools import wraps
8+
import inspect
79
import re
810
import warnings
9-
import inspect
11+
1012
import numpy as np
13+
1114
import 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
1716
from .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

Comments
 (0)