Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
Runningplt.subplot
after the respective subplot has already been created shows a warning. This behaviour is expected forfig.add_subplot
. However in pyplot this is to my knowledge the recommended way to activate a subplot, as seen fromthe tutorial.
Code for reproduction
The following is the code from the second code box in theWorking with multiple figures and axes section of the basic pyplot guide.
import matplotlib.pyplot as pltplt.figure(1) # the first figureplt.subplot(211) # the first subplot in the first figureplt.plot([1, 2, 3])plt.subplot(212) # the second subplot in the first figureplt.plot([4, 5, 6])plt.figure(2) # a second figureplt.plot([4, 5, 6]) # creates a subplot(111) by defaultplt.figure(1) # figure 1 current; subplot(212) still currentplt.subplot(211) # make subplot(211) in figure1 currentplt.title('Easy as 1, 2, 3') # subplot 211 title
Actual outcome
When being run it produces a warning.
MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
Expected outcome
No warning. Usingpyplot.subplot(211)
should just activate the subplot, as described in the tutorial.
Alternatively, there needs to be another way to activate a subplot in pyplot (without having stored any handle to it previously).
Matplotlib version
- Matplotlib version: 2.2.2, 3.0.0 (possibly others)