Simple Matplotlib usage and Gnuplot

I’m elated to have found matplotlib after struggling with octave and gnuplot.

There is one thing that I think matplotlib could improve on (or that I cannot find)

– quick plotting a la gnuplot:

plot “file.txt” using 1:2 with lp

For matplotlib, perhaps something like the following:

fplot(“filename”, cols=(1,5), delimiter=’,’, numheader=2)

This would allow quick plotting of simple columnar data files, using some (default)

assumptions of the file format. I.e, delimiter could be ‘intelligently’

chosen based on some assumptions of the file, or set explicitly. Similarly for the

number of header rows, etc.

Are there any plans for such a feature, or does it already exist? Probably would

not be too difficult to implement if no one else is planning to do so.

Thanks,

Matt

Matt Fago a �crit :

I'm elated to have found matplotlib after struggling with octave and gnuplot.

There is one thing that I think matplotlib could improve on (or that I cannot find)
-- quick plotting a la gnuplot:

   plot "file.txt" using 1:2 with lp

For matplotlib, perhaps something like the following:

   fplot("filename", cols=(1,5), delimiter=',', numheader=2)

+1

···

--
Fred, who struggled against octave/gnuplot for many years too (too much years :wink:

Matt Fago ha scritto:

I'm elated to have found matplotlib after struggling with octave and gnuplot.

There is one thing that I think matplotlib could improve on (or that I cannot find)
-- quick plotting a la gnuplot:

   plot "file.txt" using 1:2 with lp

For matplotlib, perhaps something like the following:

   fplot("filename", cols=(1,5), delimiter=',', numheader=2)

This would allow quick plotting of simple columnar data files, using some (default)
assumptions of the file format. I.e, delimiter could be 'intelligently' chosen based on some assumptions of the file, or set explicitly. Similarly for the
number of header rows, etc.

Are there any plans for such a feature, or does it already exist? Probably would
not be too difficult to implement if no one else is planning to do so.

IMHO it could be done very easily using the csv python module. I'm
currently using a script that does almost exactly that for kernel
density estimation. :slight_smile:

If someone holds my hand about mpl guidelines etc., I could try to
contribute a general fplot to pylab / mpl.

m.

···

--
Massimo Sandal
University of Bologna
Department of Biochemistry "G.Moruzzi"

snail mail:
Via Irnerio 48, 40126 Bologna, Italy

email:
massimo.sandal@...898...

tel: +39-051-2094388
fax: +39-051-2094387

There is a script called 'plotit', included with the WxMpl library, that provides very limited command-line plotting of whitespace-delimited ASCII data files, e.g.

  $ plotit '$1' '$3/$2' somedatafile anotherdatafile

There's also support for strip charting data as it arrives from stdin, but you have to communicate using an ugly legacy language. The script is currently a wxPython-only program that depends on WxMpl to embed the plot, but you could probably modify it to work using pylab without too much pain and suffering.

The WxMpl source tarball, which includes plotit, can be downloaded from

  http://agni.phys.iit.edu/~kmcivor/wxmpl/

If you just want to start hacking on the script you can pull it straight from the subversion repository instead:

  http://svn.csrri.iit.edu/mr-software/wxmpl/trunk/plotit

Ken

···

On Aug 27, 2007, at 11:59 AM, Matt Fago wrote:

Are there any plans for such a feature, or does it already exist? Probably would
not be too difficult to implement if no one else is planning to do so.

I matplotlib svn (as of June) there is a plotfile function. From the docstring:

Help on function plotfile in module matplotlib.pylab:

plotfile(fname, cols=(0,), plotfuncs=None, comments=‘#’, skiprows=0, checkrows=5, delimiter=‘,’, **kwargs)
plot the data in fname

cols is a sequence of column identifiers to plot.  An identifier
is either an int or a string.  if it is an int, it indicates the
column number.  If it is a string, it indicates the column header.

mpl will make column headers lower case, replace spaces with
strings, and remove all illegal characters; so 'Adj Close*' will
have name 'adj_close'

if len(cols)==1, only that column will be plotted on the y axis.

if len(cols)>1, the first element will be an identifier for data
for the x axis and the remaining elements will be the column
indexes for multiple subplots

plotfuncs, if not None, is a dictionary mapping identifier to an

Axes plotting function as a string.  Default is 'plot', other
choices are 'semilogy', 'fill', 'bar', etc...  You must use the
same type of identifier in the cols vector as you use in the

plotfuncs dictionary, eg integer column numbers in both or column
names in both.

comments, skiprows, checkrows, and delimiter are all passed on to
matplotlib.mlab.csv2rec to load the data into a record array


kwargs are passed on to plotting functions

Example usage:

  # plot the 2nd and 4th column against the 1st in two subplots
  plotfile(fname, (0,1,3))

  # plot using column names; specify an alternate plot type for volume

  plotfile(fname, ('date', 'volume', 'adj_close'), plotfuncs={'volume': 'semilogy'})
···

On 8/27/07, Matt Fago <fago@…44…> wrote:

I’m elated to have found matplotlib after struggling with octave and gnuplot.

There is one thing that I think matplotlib could improve on (or that I cannot find)

– quick plotting a la gnuplot:

plot “file.txt” using 1:2 with lp

For matplotlib, perhaps something like the following:

fplot(“filename”, cols=(1,5), delimiter=‘,’, numheader=2)

John Hunter a �crit :

I matplotlib svn (as of June) there is a plotfile function. From the docstring:

Great !

Thanks.

···

--
http://scipy.org/FredericPetit