I want to automatically generated hundreds of figures with matplotlib.
For each figure, I could use 'plot(Xi)' and 'show()' to draw the figure,
and press the 'save' button in the figure panel, but this is not too
automatically. Although I could use 'savefig()' to save the figures
rather than using 'show()' to show it, and this makes whole program
fully automatically, I don't know howto set the figure size before
'save' it (e.g. set size to 3000x1000pixel). The function 'savefig()'
doesn't have any option to set figure size. So which function should I
go to? or what should I do before using 'savefig()'?
You have two options. savefig does have a dpi option that will
essentially set the figure size for the saved file:
savefig('myfile.png',dpi=300)
play with dpi until you get a figure size you like.
The other way to set the figure size is to specify it when you create
the figure:
figure(1,(10,8))
would create a fairly large figure. The figure (1 in this case) must
not already exist or at least it can't be shown on your screen
already. By that I mean if you have already called figure(1)
previously in your code, you must close it before you try to call
figure(1,(10,8)) or the figure size won't be affected.
I want to automatically generated hundreds of figures with matplotlib.
For each figure, I could use 'plot(Xi)' and 'show()' to draw the figure,
and press the 'save' button in the figure panel, but this is not too
automatically. Although I could use 'savefig()' to save the figures
rather than using 'show()' to show it, and this makes whole program
fully automatically, I don't know howto set the figure size before
'save' it (e.g. set size to 3000x1000pixel). The function 'savefig()'
doesn't have any option to set figure size. So which function should I
go to? or what should I do before using 'savefig()'?