I want to plot data, in two different subplots. After plotting, I want to go back to the first subplot and plot an additional dataset in it. However, when I do so I get this
I had the same problem. I used to have the following code that raised the warning:
(note that the variable Image
is simply my image saved as numpy array)
import numpy as np
import matplotlib.pyplot as plt
plt.figure(1) # create new image
plt.title("My image") # set title
# initialize empty subplot
AX = plt.subplot() # THIS LINE RAISED THE WARNING
plt.imshow(Image, cmap='gist_gray') # print image in grayscale
... # then some other operations
and I solved it, modifying like this:
import numpy as np
import matplotlib.pyplot as plt
fig_1 = plt.figure(1) # create new image and assign the variable "fig_1" to it
AX = fig_1.add_subplot(111) # add subplot to "fig_1" and assign another name to it
AX.set_title("My image") # set title
AX.imshow(Image, cmap='gist_gray') # print image in grayscale
... # then some other operations