how to delete matplotlib data between ploting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • riklaunim@gmail.com

    #1

    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.replac e('.', ' '))
    #plot
    plot(x, y)
    savefig('dane/' + di + '/' + datafile + '.png')
    del x
    del y
    del file

  • Murali

    #2
    Re: how to delete matplotlib data between ploting

    pylab.clf() or some such thing clears the current canvas.

    riklaunim@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.replac e('.', ' '))
    #plot
    plot(x, y)
    savefig('dane/' + di + '/' + datafile + '.png')
    del x
    del y
    del file

    Comment

    • riklaunim@gmail.com

      #3
      Re: how to delete matplotlib data between ploting

      clf() works :) thanks

      Comment

      Working...