8000 `Axes3d` attaches itself to a figure, where as `Axes` does not · Issue #18364 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Axes3d attaches itself to a figure, where as Axes does not #18364
Closed
@jklymak

Description

@jklymak
import matplotlib.pyplot as plt
import matplotlib.axes as maxes

fig = plt.figure()
ax = maxes.Axes(fig, [0.1, 0.1, 0.9, 0.9])
print(fig.get_children())

returns a list with no axes....

[<matplotlib.patches.Rectangle object at 0x7f8d75707dc0>]

For 3-d

import matplotlib.pyplot as plt
import matplotlib.axes as maxes
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = Axes3D(fig)
print(fig.get_children())

has the axes attached:

[<matplotlib.patches.Rectangle object at 0x7fbc2968d160>, <mpl_toolkits.mplot3d.axes3d.Axes3D object at 0x7fbc2968df40>]

Axes3D.__init__ explicitly adds itself to its parent:

self.figure.add_axes(self)

whereas no such thing happens for the base Axes class.

Discovered as part of #18356, but discussing here because its orthogonal. But I think the behaviour here should be the same .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0