python - Why does pylab.savefig() add multiple plots when pylab.show() doesn't and how can I make it stop? -
my program computes number of diagrams, each multiple plots. when executed using pylab.show()
, shows first diagram in window , when close window shows second diagram , on, fine.
when using pylab.savefig()
, second diagram contains both plots first , second diagram.
how keep savefig()
accumulating plots?
this code i'm using plot diagrams:
# generate multiple plots first diagram label = 4 in nylonlengthlists: # take list of lists generate multiple plots pylab.plot(windspeeds,i, label=str(label) + ' m') label += 1 pylab.title('leinenlaengen nach tiefen') pylab.ylabel('leinenlaenge (m)') pylab.xlabel('windgeschwindigkeit (kn)') pylab.legend(loc='upper left', title='tiefen') pylab.xticks() pylab.grid() pylab.savefig('diagram1.png') # generate plots second diagram nylonlengthlists = [] # reset , regenerate list of lists in range(12,25,2): nylonlengthlists.append(nylonlengthlist(i, chainlength, boatlength)) label = 12 in nylonlengthlists: # generate multiple plots pylab.plot(windspeeds,i, label=str(label) + ' m') label += 2 pylab.title('leinenlaengen nach tiefen') pylab.ylabel('leinenlaenge (m)') pylab.xlabel('windgeschwindigkeit (kn)') pylab.legend(loc='upper left', title='tiefen') pylab.xticks() pylab.grid() pylab.savefig('diagram2.png')
closing matplotlib window after pylab.show
destroys figure instance. new 1 created @ next plotting command.
to multiple figures without show
, call pylab.figure
each time want start new plot.
Comments
Post a Comment