I am working on jupyter notebook and I am using matplotlib.pyplot.subplot()
inside a for loop. In the same cell of the for loop, I called plt.show()
to show the graphs. However, they are too small, so I am looking to replot them on another notebook cell without having to repeat the loop, which is time-consuming.
So basically I ran the cell with a code that looks like this:
import matplotlib.pyplot as plt
import numpy as np
fig, axs = plt.subplots(5,1)
for ii in range(5):
#some time consuming operations
axs[ii].plot(np.random.randn(10))
plt.show()
I realise that the figure is too small so in the subsequent cell I would like to reshow the previous plots on a larger figure. Since all the information is contained in fig
and axs
I am assuming that I do not have to repeat the loop but just to tell matplotlib to show again the plots whose information should already be in the axs
variable.