Skip to content

Commit 5220ebe

Browse files
authored
Fix subplot docs (#29471)
* doc:updates the docstring * fixed linting error * Fixed failing test of Python 3.12 * fix:remove trailing whitespace
1 parent 0a0b9ac commit 5220ebe

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

doc/api/axes_api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -620,5 +620,6 @@ Other
620620
Axes.get_transformed_clip_path_and_affine
621621
Axes.has_data
622622
Axes.set
623+
Axes.remove
623624

624625
.. autoclass:: matplotlib.axes.Axes.ArtistList

lib/matplotlib/pyplot.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -1450,16 +1450,10 @@ def subplot(*args, **kwargs) -> Axes:
14501450
14511451
Notes
14521452
-----
1453-
Creating a new Axes will delete any preexisting Axes that
1454-
overlaps with it beyond sharing a boundary::
1455-
1456-
import matplotlib.pyplot as plt
1457-
# plot a line, implicitly creating a subplot(111)
1458-
plt.plot([1, 2, 3])
1459-
# now create a subplot which represents the top plot of a grid
1460-
# with 2 rows and 1 column. Since this subplot will overlap the
1461-
# first, the plot (and its Axes) previously created, will be removed
1462-
plt.subplot(211)
1453+
.. versionchanged:: 3.8
1454+
In versions prior to 3.8, any preexisting Axes that overlap with the new Axes
1455+
beyond sharing a boundary was deleted. Deletion does not happen in more
1456+
recent versions anymore. Use `.Axes.remove` explicitly if needed.
14631457
14641458
If you do not want this behavior, use the `.Figure.add_subplot` method
14651459
or the `.pyplot.axes` function instead.

0 commit comments

Comments
 (0)