how to delete matplotlib data between ploting

R

riklaunim

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top