Skip to content

Commit 6c5b302

Browse files
committed
Remove renderer properties
1 parent 6ef6b37 commit 6c5b302

File tree

2 files changed

+48
-58
lines changed

2 files changed

+48
-58
lines changed

doc/api/next_api_changes/removals/00001-DS.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Removal of deprecated arguments in mplot3d
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1+
Removal of mplot3d deprecations
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
The deprecated ``renderer`` arguments have been removed from:
44

55
- `.Line3DCollection.do_3d_projection`
@@ -15,3 +15,14 @@ The deprecated ``project`` argument has also been removed from
1515
Passing arguments not specifically listed in the signatures of
1616
`.Axes3D.plot_surface` and `.Axes3D.plot_wireframe` is no longer supported.
1717
Pass any extra arguments as keyword arguments instead.
18+
19+
These properties of the 3D Axes that were placed on the Renderer during draw
20+
have been removed:
21+
22+
* ``renderer.M``
23+
* ``renderer.eye``
24+
* ``renderer.vvec``
25+
* ``renderer.get_axis_position``
26+
27+
These attributes are all available via `.Axes3D`, which can be accessed via
28+
``self.axes`` on all `.Artist`\s.

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -405,62 +405,41 @@ def draw(self, renderer):
405405

406406
# add the projection matrix to the renderer
407407
self.M = self.get_proj()
408-
props3d = {
409-
# To raise a deprecation, we need to wrap the attribute in a
410-
# function, but binding that to an instance does not work, as you
411-
# would end up with an instance-specific method. Properties are
412-
# class-level attributes which *are* functions, so we do that
413-
# instead.
414-
# This dictionary comprehension creates deprecated properties for
415-
# the attributes listed below, and they are temporarily attached to
416-
# the _class_ in the `_setattr_cm` call. These can both be removed
417-
# once the deprecation expires
418-
name: _api.deprecated('3.4', name=name,
419-
alternative=f'self.axes.{name}')(
420-
property(lambda self, _value=getattr(self, name): _value))
421-
for name in ['M', 'vvec', 'eye', 'get_axis_position']
422-
}
423-
424-
with cbook._setattr_cm(type(renderer), **props3d):
425-
def do_3d_projection(artist):
426-
"""
427-
Call `do_3d_projection` on an *artist*.
428-
"""
429-
return artist.do_3d_projection()
430-
431-
collections_and_patches = (
432-
artist for artist in self._children
433-
if isinstance(artist, (mcoll.Collection, mpatches.Patch))
434-
and artist.get_visible())
435-
if self.computed_zorder:
436-
# Calculate projection of collections and patches and zorder
437-
# them. Make sure they are drawn above the grids.
438-
zorder_offset = max(axis.get_zorder()
439-
for axis in self._get_axis_list()) + 1
440-
collection_zorder = patch_zorder = zorder_offset
441-
for artist in sorted(collections_and_patches,
442-
key=do_3d_projection,
443-
reverse=True):
444-
if isinstance(artist, mcoll.Collection):
445-
artist.zorder = collection_zorder
446-
collection_zorder += 1
447-
elif isinstance(artist, mpatches.Patch):
448-
artist.zorder = patch_zorder
449-
patch_zorder += 1
450-
else:
451-
for artist in collections_and_patches:
452-
artist.do_3d_projection()
453-
454-
if self._axis3don:
455-
# Draw panes first
456-
for axis in self._get_axis_list():
457-
axis.draw_pane(renderer)
458-
# Then axes
459-
for axis in self._get_axis_list():
460-
axis.draw(renderer)
461-
462-
# Then rest
463-
super().draw(renderer)
408+
409+
collections_and_patches = (
410+
artist for artist in self._children
411+
if isinstance(artist, (mcoll.Collection, mpatches.Patch))
412+
and artist.get_visible())
413+
if self.computed_zorder:
414+
# Calculate projection of collections and patches and zorder
415+
# them. Make sure they are drawn above the grids.
416+
zorder_offset = max(axis.get_zorder()
417+
for axis in self._get_axis_list()) + 1
418+
collection_zorder = patch_zorder = zorder_offset
419+
420+
for artist in sorted(collections_and_patches,
421+
key=lambda artist: artist.do_3d_projection(),
422+
reverse=True):
423+
if isinstance(artist, mcoll.Collection):
424+
artist.zorder = collection_zorder
425+
collection_zorder += 1
426+
elif isinstance(artist, mpatches.Patch):
427+
artist.zorder = patch_zorder
428+
patch_zorder += 1
429+
else:
430+
for artist in collections_and_patches:
431+
artist.do_3d_projection()
432+
433+
if self._axis3don:
434+
# Draw panes first
435+
for axis in self._get_axis_list():
436+
axis.draw_pane(renderer)
437+
# Then axes
438+
for axis in self._get_axis_list():
439+
axis.draw(renderer)
440+
441+
# Then rest
442+
super().draw(renderer)
464443

465444
def get_axis_position(self):
466445
vals = self.get_w_lims()

0 commit comments

Comments
 (0)