Skip to content

Commit d96fa55

Browse files
committed
MNT: Restore auto-adding Axes3D to their parent figure on init
Only do this when directly created by the user, not via our machinery.
1 parent 56d9e7c commit d96fa55

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/matplotlib/figure.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,9 @@ def _process_projection_requirements(
15171517
raise TypeError(
15181518
f"projection must be a string, None or implement a "
15191519
f"_as_mpl_axes method, not {projection!r}")
1520-
1520+
if projection_class.__name__ == 'Axes3D':
1521+
print(f'{projection_class=}')
1522+
kwargs['__internal'] = True
15211523
return projection_class, kwargs
15221524

15231525
def get_default_bbox_extra_artists(self):

lib/mpl_toolkits/mplot3d/axes3d.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ def __init__(
9696
if sharez is not None:
9797
self._shared_z_axes.join(self, sharez)
9898
self._adjustable = 'datalim'
99-
99+
internal_call = kwargs.pop('__internal', False)
100100
super().__init__(
101101
fig, rect, frameon=True, box_aspect=box_aspect, *args, **kwargs
102102
)
103+
103104
# Disable drawing of axes by base class
104105
super().set_axis_off()
105106
# Enable drawing of axes by Axes3D class
@@ -128,6 +129,8 @@ def __init__(
128129
# mplot3d currently manages its own spines and needs these turned off
129130
# for bounding box calculations
130131
self.spines[:].set_visible(False)
132+
if not internal_call:
133+
fig.add_axes(self)
131134

132135
def set_axis_off(self):
133136
self._axis3don = False

0 commit comments

Comments
 (0)