Generating charts in a loop

Hi folks,

I would like to generate matplotlib scatter plots in a python ‘for’ loop.

However, I am running into the following problem. The first scatter plot is fine, each subsequent scatter plot still has the points from the previous scatter plot, even though I am generating a new list with each iteration. This results in the last scatter plot to have a gigantic number of points.

Here is sample code:

for x in dates:
xpoints = [ ]
ypoints = [ ]
size = [ ]
. . . .
. . . . .

xticker = arange(0,6000, 1000)
yticker = arange(-4, 10, 1)

xticks(xticker)
yticks(yticker)

scatter(xpoints,ypoints, s = size)

savefig('example.png')

Any suggestions?

Thanks in advance.

Use 'figure'.

hth,
Alan Isaac

···

On Wed, 15 Mar 2006, Imara Jarrett wrote:

I would like to generate matplotlib scatter plots in a python 'for' loop.