Multiple plots from multiple files in one figure?

Tom, please subscribe to matplotlib users at and
direct questions to the mailing list rather than me directly. I'm
forwarding this question on to the list


---------- Forwarded message ----------
From: <eeguy@...2100...>
Date: Sat, Jul 19, 2008 at 9:59 AM
Subject: Multiple plots from multiple files in one figure?
To: jdh2358@...287...


Thanks for all the great work.

I'm new to both matplotlib & Python, so please forgive any ignorance.
I would like to plot multiple CSV files on a single set of axes.
Specifically, I want to duplicate your Yahoo ticker data example, but
plotting multiple tickers on the same figure so that I can compare

Is there some easy way to do this?

Thanks for the help.


John Hunter-4 wrote:

On 6/8/07, Lionel Roubeyrie <lroubeyrie@...1068...> wrote:

Hi John,
very very interesting idea.
Is there a way to add some extras informations on the records arrays
like the units or/and the desired labels for the resulting plotted lines,
directly retrieved in the CSV files?

It could be done, but my goal here is not to create a persistence
layer for record arrays, or a method of describing them or mpl labels,
but rather a way to easily import 3rd party CSV files into numpy
record arrays. I work with a lot of tab/space/ascii delimited files,
and found myself duplicating a lot of code importing them into record
arrays. This function is the distillation of that code. It would be
fairly easy to add designated rows for those who did want to decorate
their CSV files. I think it might be most useful to support a row
that provided a numpy dtype per column, or perhaps the name of a
converter function...

One thing people coming from gnuplot miss is file plotting
functionality. I just added a function to pylab called plotfile which
uses the csv2rec functionality (with autolabeling etc) to plot data
from a file. Eg,

plotfile(fname, (0,5,6))

plots columns 5 and 6 against column 0. And

plotfile(fname, ('date', 'volume', 'adj_close'),

plotfuncs={'volume': 'bar'})

does the same using the names of the columns, using "plot" for
adj_close (the default) and "bar" for volume (customization from the
plotfuncs dictionary). The column names in either case are used to
create default x and y labels.

The 2nd command produces the attached plot. This is just a first
pass, so if people want to see a different interface or have an
opinion what should be returned, or where this function should live
outside of pylab, feel free to comment or commit changes.


This email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
Matplotlib-users mailing list
matplotlib-users List Signup and Options

Quoted from: