how to delete matplotlib data between ploting
Murali
gmkrishn.uofc at gmail.com
Thu Dec 7 13:21:32 EST 2006
pylab.clf() or some such thing clears the current canvas.
riklaunim at gmail.com wrote:
> I want to make few plots from CSV files. I have the code below - it
> works - the first plot is ok, the second one has the first and the
> current data set and so on - I can't delete the plot data between
> plots.
> ##########################################
> # -*- coding: utf-8 -*-
> from pylab import *
> from os import listdir
>
> i = listdir('dane/')
>
> # list folders with CSV files
> for di in i:
> # list files in folders
> csv = listdir('dane/' + di + '/')
> for datafile in csv:
> # open each CSV file
> file = open('dane/' + di + '/' + datafile, 'r').readlines()
> x = []
> y = []
> # get the data
> for row in file:
> if row.find(',') != -1:
> r = row.split(',')
> if len(r[0]) > 0 and len(r[1]) > 0:
> x.append(float(r[0]))
> y.append(float(r[1]))
> xlabel('czas')
> ylabel('Moc')
> title(di.replace('.', ' '))
> #plot
> plot(x, y)
> savefig('dane/' + di + '/' + datafile + '.png')
> del x
> del y
> del file
More information about the Python-list
mailing list