Hi I am experiencing subplotting in a loop. I failed to plot with using below code. The bottom subplot is empty
x=[1,2,3]
y=[4,5,6]
fig, ax = plt.subplots(2,1, sharex = True)
for n in range(2):
ax[n].plot(x,y)
plt.show()
the failed plot looks like this. Any thoughts?
CodePudding user response:
Move plt.show()
outside the for loop:
for n in range(2):
ax[n].plot(x,y)
plt.show()
CodePudding user response:
Is this how you wanted it to be ??
x=[1,2,3]
y=[4,5,6]
fig, ax = plt.subplots(2,1,sharex = True)
for n in range(2):
ax[n].plot(x,y)
plt.show()