diff --git a/doc/api/axes_api.rst b/doc/api/axes_api.rst index f389226d907a..030655458c26 100644 --- a/doc/api/axes_api.rst +++ b/doc/api/axes_api.rst @@ -620,5 +620,6 @@ Other Axes.get_transformed_clip_path_and_affine Axes.has_data Axes.set + Axes.remove .. autoclass:: matplotlib.axes.Axes.ArtistList diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 2dd14404c98e..43c4ac70bff0 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1450,16 +1450,10 @@ def subplot(*args, **kwargs) -> Axes: Notes ----- - Creating a new Axes will delete any preexisting Axes that - overlaps with it beyond sharing a boundary:: - - import matplotlib.pyplot as plt - # plot a line, implicitly creating a subplot(111) - plt.plot([1, 2, 3]) - # now create a subplot which represents the top plot of a grid - # with 2 rows and 1 column. Since this subplot will overlap the - # first, the plot (and its Axes) previously created, will be removed - plt.subplot(211) + .. versionchanged:: 3.8 + In versions prior to 3.8, any preexisting Axes that overlap with the new Axes + beyond sharing a boundary was deleted. Deletion does not happen in more + recent versions anymore. Use `.Axes.remove` explicitly if needed. If you do not want this behavior, use the `.Figure.add_subplot` method or the `.pyplot.axes` function instead.