From 2218b3b61d12e7dce7eb07ace7cab37116675f57 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Wed, 14 Dec 2022 14:20:56 -0600 Subject: [PATCH] Backport PR #24715: Add note that users do not instantiate Axes directly --- lib/matplotlib/axes/_axes.py | 6 ++++++ lib/mpl_toolkits/mplot3d/axes3d.py | 6 ++++++ tutorials/toolkits/mplot3d.py | 4 ---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 4f4d8b6c0389..5c72df48aa8e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -55,6 +55,12 @@ class Axes(_AxesBase): are 'xlim_changed' and 'ylim_changed' and the callback will be called with func(*ax*) where *ax* is the `Axes` instance. + .. note:: + + As a user, you do not instantiate Axes directly, but use Axes creation + methods instead; e.g. from `.pyplot` or `.Figure`: + `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` or `.Figure.add_axes`. + Attributes ---------- dataLim : `.Bbox` diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 73af916f6690..533901ac64da 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -45,6 +45,12 @@ class Axes3D(Axes): """ 3D Axes object. + + .. note:: + + As a user, you do not instantiate Axes directly, but use Axes creation + methods instead; e.g. from `.pyplot` or `.Figure`: + `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` or `.Figure.add_axes`. """ name = '3d' diff --git a/tutorials/toolkits/mplot3d.py b/tutorials/toolkits/mplot3d.py index d0d964ee7066..f3ff920e036f 100644 --- a/tutorials/toolkits/mplot3d.py +++ b/tutorials/toolkits/mplot3d.py @@ -24,10 +24,6 @@ :target: ../../gallery/mplot3d/subplot3d.html :align: center -.. versionchanged:: 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)``. - .. versionchanged:: 3.2.0 Prior to Matplotlib 3.2.0, it was necessary to explicitly import the :mod:`mpl_toolkits.mplot3d` module to make the '3d' projection to