Creating Charts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Guettler

    Creating Charts

    Hi!

    I need to create some simple charts with python.
    A list contains integers between 0 and mymax.

    I want to see how the values are distributed (How
    many are 0, how many are mymax, ...). The result should
    be a small (200x200) png file.

    I searched a bit:
    - gnuplot: Too big, too complicated
    - matplotlib: Too much gtk binding (I only need a png)
    - reportlib: Needs PIL. First try failed (_renderPM missing)

    Any hints on how to create charts?
    There need not to be a python-binding. I can
    call the external application with os.system().

    Operating System: Linux 2.4.20

    Thanks,
    Thomas

  • John Hunter

    #2
    Re: Creating Charts

    >>>>> "Thomas" == Thomas Guettler <guettli@thom as-guettler.de> writes:

    Thomas> Hi! I need to create some simple charts with python. A
    Thomas> list contains integers between 0 and mymax.

    Thomas> I want to see how the values are distributed (How many are
    Thomas> 0, how many are mymax, ...). The result should be a small
    Thomas> (200x200) png file.

    Thomas> matplotlib: Too much gtk binding (I only need a png) -

    The web page may have given this impression, but it's not correct.
    matplotlib is totally independent of GTK. It *can* render to GTK, but
    it isn't required. GTK was the first matplotlib backend and perhaps
    this is why is gets so much prominence on the web page. But now you
    can use it with GTK, WX or Tk, or none of the above to simply generate
    PNG or PS figures.

    To render to PNG w/o a GUI, use the antigrain (agg) backend as
    described at http://matplotlib.sourceforge.net/backends.html#Agg.

    Basically, you just need

    * Download the src distribution, edit setup.py and set BUILD_AGG =
    True, do a normal setup.py install.

    * Edit the config file to make agg your default backend by setting

    backend : Agg

    in your matplotlibrc file; see
    http://matplotlib.sourceforge.net/.matplotlibrc. This file should
    be placed in your HOME dir.

    Then you can make your small histogram figure as follows

    from matplotlib.matl ab import *
    x = someInts # your data here
    hist(x, 100) # 100 is the number of histogram bins
    savefig('myfig. png', figsize=(4,4)) # figsize in inches

    Hope this helps,
    John Hunter

    Comment

    • Larry Bates

      #3
      Re: Creating Charts

      I use Reportlib/Graphics and it works well for me.
      I have one project where I generate nearly 8,000
      unique barcharts (grading data for every school
      in my state) and it is very fast.

      I don't see the PIL requirement as bad, I use PIL
      for lots of other projects also. Getting this
      going is worth the effort.

      Larry Bates
      Syscon, Inc.


      "Thomas Guettler" <guettli@thom as-guettler.de> wrote in message
      news:pan.2004.0 3.31.07.23.50.1 0533@thomas-guettler.de...[color=blue]
      > Hi!
      >
      > I need to create some simple charts with python.
      > A list contains integers between 0 and mymax.
      >
      > I want to see how the values are distributed (How
      > many are 0, how many are mymax, ...). The result should
      > be a small (200x200) png file.
      >
      > I searched a bit:
      > - gnuplot: Too big, too complicated
      > - matplotlib: Too much gtk binding (I only need a png)
      > - reportlib: Needs PIL. First try failed (_renderPM missing)
      >
      > Any hints on how to create charts?
      > There need not to be a python-binding. I can
      > call the external application with os.system().
      >
      > Operating System: Linux 2.4.20
      >
      > Thanks,
      > Thomas
      >[/color]


      Comment

      Working...