473,378 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to delete matplotlib data between ploting

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

Dec 7 '06 #1
2 5939
pylab.clf() or some such thing clears the current canvas.

ri*******@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
Dec 7 '06 #2
clf() works :) thanks

Dec 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Grant Edwards | last post by:
I downloaded examples/contour_demo.py, and it doesn't run. I've searched both the user guide and the Wiki for "contour" and got zero hits. ...
3
by: vajratkarviraj | last post by:
i hav python2.5, matplotlib0.90.1, and py2exe for python 2.5 all on windows xp... i hav a python program(letsc.py) which uses the matplotlib package... and i want 2 make an exe of it for distribution...
4
by: John Henry | last post by:
Has anybody been able to create an exe of their python applications involving matplotlib using pyinstall (ver 1.3)? I am getting a: RuntimeError: Could not find the matplotlib data files when...
0
by: PamMish1982 | last post by:
Hi all, I have recently started using Python and I am trying to make a GUI out of Tkinter. I am using matplotlib for the graphic purposes. I have to make a exe file from this code. I use py2exe...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.