0

I'm having troubles understanding why images are not showing up properly in the subplots in my code. To my understanding, when you create a figure with multiple subplots, you are able to access each of the subplot and plot the corresponding graph.

Here's what I have written. I'm trying to create a 1*4 plot, where each subplot contains a curve depending on some conditional information on a matrix X:

fig, axs = plt.subplots(1,4, figsize=[12,3])

for i in range (2, 6):
    c = X[np.where(X[:, 2] == i)]    
    axs[i-2].plot(X[:, 0],X[:, 1])
    plt.show()

For whatever reason, I'm only getting information on the first subplot. All the other three subplots are empty... Any help would be appreciated!

------update: I figured out that it's because I had plt.show() inside the for loop...but I still don't understand why it would only show one plot. Shouldn't it show all the subplots?

CharlieCCC
  • 21
  • 5

0 Answers0