FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: The Axes3D does not work as expected. · Issue #24639 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: The Axes3D does not work as expected. #24639

Closed

Description

Bug summary

The Axes3D does not work as expected.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D


plt.style.use('_mpl-gallery')

# Make data
np.random.seed(19680801)
n = 100
rng = np.random.default_rng()
xs = rng.uniform(23, 32, n)
ys = rng.uniform(0, 100, n)
zs = rng.uniform(-50, -25, n)

# Plot
# fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(xs, ys, zs)

ax.set(xticklabels=[],
       yticklabels=[],
       zticklabels=[])

plt.show()

Actual outcome

The outcome figure is blank.

Expected outcome

Should show figure with correct content.

Additional information

The code works well if changed to
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})

Operating system

Windows

Matplotlib Version

3.6.2

Matplotlib Backend

Qt5Agg

Python version

3.9.15

Jupyter version

NA

Installation

conda

Activity

  1. changed the title [-][Bug]: [/-] [+][Bug]: The Axes3D does not work as expected.[/+] on Dec 6, 2022
  2. timhoffm commented on Dec 6, 2022

    Member

    Axes objects need correct wiring up with the figure. Therefore, you never instantiate any Axes directly, but use the Axes creation methods on Figure (or pyplot), which do that logic for you.I think this is consistently shown throughout our documentation. Have you found a place that suggests otherwise?

    Todo: Maybe we should add a note to Axes constructors that they are not intended for the end-user.

  3. oscargus commented on Dec 6, 2022

    Member

    There is a note here: https://matplotlib.org/stable/tutorials/toolkits/mplot3d.html

    "Changed in version 1.0.0: Prior to Matplotlib 1.0.0, only a single Axes3D could be created per figure; it needed to be directly instantiated as ax = Axes3D(fig)."

    This can possibly be dropped now? But also it indicates that there are old examples out there using this.

    (Some tests use ax = fig.add_axes(Axes3D(fig)) so that is, I guess, the way to do it if one really wants to instantiate it separately, but not the way to go.)

  4. added 2 commits that reference this issue on Dec 13, 2022
    5595874
    de8d265
  5. tacaswell commented on Dec 14, 2022

    Member

    Between this issue and #24725 what is happening that this came up 2x in a week or so but not for the last 4 months from when 3.6 came out?

  6. added this to the v3.6.3 milestone on Dec 15, 2022
  7. added a commit that references this issue on Dec 19, 2022
    cb0232e
  8. added 3 commits that reference this issue on Apr 19, 2026
    7e38d64
    65cea2a
    e843826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL