[Tutor] matplotlib.pylab.plotfile formatting help

Evert Rol evert.rol at gmail.com
Tue Jan 4 17:02:01 CET 2011


  Hi Sean,

> I've got a csv file that contains two data fields, the short name of a
> month and an integer.  I'm experimenting with pylab and ipython to get
> a feel for how pylab works.  I'm able to generate a bar graph from my
> data, but there are two problems with it:
> 
> 1.  I don't want "2011" appended to the month names.  This data is
> from 2010, and I only want the short month name under each bar.
> 2.  The bars are very narrow and I'm not sure how to widen them.
> 
> Here's my CSV data, stored in a file called csvdata.csv:
> 
> month,systems
> Jan,17
> <snip>
> Dec,197
> 
> And here's the "ipython -pylab" command that I'm using to generate the graph:
> 
> plotfile('csvdata.csv', ('month', 'systems'), plotfuncs={'systems': 'bar'},)
> 
> I've read through some of the documentation for matplotlib, but having
> never used matlab or pylab before today it's a bit confusing.  Does
> anyone know how to solve #1 and #2 above?

I've never used plotfile before, but it seems like a simple quick'n'dirty function, good for having a quick glance at how the data look like. Which is also what the documentation for plotfile says.
So in this case, your points 1 and 2 can be solved using the more generic approach, reading the file separately (possibly using a csv module) and using pylab.bar to plot your data. pylab.bar has a 'width' option, which would easily solve problem #2.

I can also advice you to try the matplotlib mailing list: people will there will be much more knowledgeable wrt to matplotlib and pylab than on this mailing list: http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users

Good luck,

  Evert




More information about the Tutor mailing list