numpy - Python: Creating multiple plots in one figure with for loop -


i have tried create 2 row, 3 column grid of plots (each having multiple data plotted on it) using matplotlib. however, no matter try, final saved figure 1 of plots, rest blank. know other produced, not appearing in final image. here 1 basic version of i'm trying.

the commented out pieces show alternatives have seen.

f,axarr = plt.subplots(2,3, sharex='col', sharey='row')  i,someargs in enumerate(namelist):     x1,y1,x2,y2 = somefunction(someargs)  #output data     ax = axarr.flat[i]  #or ax=axarr[row,col]     ax.plot(x1,y1)     ax.plot(x2,y2) plt.savefig("name") #or f.savefig("name") 

is there wrong way doing this? image getting located @ http://i.imgur.com/qxyrnpt.png appreciated.

here way can use loop generate subplots , can hide axes not need:

import pylab plt import numpy np fig ,axs=plt.subplots(2,3, sharex='col', sharey='row') axs[-1,-1].axis('off') namelist=['a','b','c','d','e'] ax=axs.ravel() i,someargs in enumerate(namelist):     x1,y1,x2,y2 = somefunction(someargs)     ax[i].plot(x1,y1)     ax[i].plot(x2,y2) 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -