Update of matplotlib graph data series in interactive mode

199 views Asked by At

IPython, QtConsole, matplotlib.pyplot.plot, qt backend. I need to redraw the plot after updating data series (DataFrame instance) itself.

This answer does not quite does it, since it relates to graph elements themselves being updated, while I want to get them updated on DataFrame modification.

I'm using this function for plotting:

def ulegend(df, *columns, **kwargs):
    pyplot.close()
    columns = list(columns)
    col_regex = kwargs.get('col_regex')
    if col_regex:
        colnames = list(df.columns)
        colnames = filter(bool, map(lambda x: re.search(col_regex, x) and x, colnames))
        columns.extend(colnames)
    lines = plot(df[list(columns)])
    pyplot.legend(lines, columns)
    return lines

Basic but does the job. pyplot returns a list of Line2D instances and I have no idea how to change the same line instance as to get it updated with changed df Series (is this, i.e. DataFrame's Series object that pyplot uses for plotting?). This is what I'm after.

0

There are 0 answers