By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,544 Members | 1,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,544 IT Pros & Developers. It's quick & easy.

Creating Charts

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>>>>> "Thomas" == Thomas Guettler <gu*****@thomas-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.matlab 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

Jul 18 '05 #2

P: n/a
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" <gu*****@thomas-guettler.de> wrote in message
news:pa***************************@thomas-guettler.de...
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

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.