plotting data against a time axis

John Hunter <jdhunter@...4...> writes:

    >> There are a lot of good plotting libraries out there. I'll
    >> pitch mine. http://matplotlib.sourceforge.net

    > Thanks for posting this! I've been using gdchart for a
    > long time because it's simple and the graphs aren't too
    > bad. But it's very limited, in particular your X axis has
    > to be equally spaced.

Hi Nelson, thanks for the email and the detailed comments. It would
be great to have you join the mailing list - other users would benefit
from your comments -

    > I spent about an hour with matplotlib. It's clear you put
    > a lot of work into this, and I think this could be a
    > really great library. Some thoughts for you from a casual
    > user:

    > The installation prerequisites are a bit daunting but on a
    > Debian system it's not too bad. Debian has many of the
    > packages you need: apt-get install python2.3-numeric
    > python2.3-numarray python2.3-numeric-ext apt-get install
    > fonttools libgd2-dev python2.3-gtk2 python2.3-numeric-ext
    > is easy to forget: you need that for FFT and MLab.

I'll update the web page with this information for debian users.
Debian is great; unfortunately, I don't get much opportunity to use it
so I haven't gone through the process of installing matplotlib on
debian. There was some interest on the mailing list earlier about
getting matplotlib packaged for debian, and an RFP was made, but I
don't there has been any any progress on this front. Charles, Nathan,
any comments here?

    > The only things I had to install from sources were
    > TTFQuery and gdmodule, and both of those were easy.

    > I'd like to use this module as a simple thing to create
    > PNGs of graphs from data to put on web pages. The GD
    > driver is most of what I need, and the idea that I could
    > also do postscript output is great. But the packaging of
    > matplotlib is a bit funky. The most confusing thing was
    > the way you read sys.argv - that's probably not good for a
    > resuable library.

I agree to a certain extent. But I don't modify the args and they
will be without effect if you use the incantation, as you did

import matplotlib
matplotlib.use('GD')

Mainly, I did it because I wanted an easy way to switch between
backends without switching scripts. There are other ways to do this
however. Unless the presence of the sys.argv is causing a problem, I
am hesitant to remove it to maintain backwards compatibility. If you
can think of a problem, please let me know.

    > I was also mystified as to how to set the plotsize using
    > the matlab module. I gave up and ended up doing something
    > else, but it was so much work I felt like I probably did
    > something wrong:

    > import matplotlib
    > matplotlib.use('GD')
    > from matplotlib.backends import Figure
    > from matplotlib.axes import Subplot

    > f = Figure(figsize=(3, 2), dpi=100)
    > a = Subplot(111)
    > a.plot([1,2,3,4], [1,4,9,16])
    > f.add_axis(a)
    > f.print_figure("nelson2.png", 100)

You're right on the money here. The ability to control the dpi,
figsize and other attributes from the matlab interface is limited. I
think I'll add kwargs to the fig command to enable this, and plan to
go to a backend specific config file for the next release -- a
.matplotlibrc file containing a dictionary that provided default font,
figsize, dpi, etc, for each backend. But beyond this, it is important
to be able to control these attributes at the script level using the
matlab interface.

I'm glad you figured out the workaround by using the API.

JDH