Custom Charts w/ Perl and GD
An anonymous reader writes "This article describes techniques you can use to create new levels of usefulness in your dynamically generated charts with Perl and GD. Cook up some automatically generated graphs for your organizational meetings or live enterprise directory data. Annotate the charts with readable text that delivers more information than the standard pie chart. Using the power of GD and Perl, you can link various data and images together to create sophisticated charts that will help bring visual interest to your applications."
"Our next exciting story - a new article from BlahBlah.com with details on how to add active javascript links to your HTML!". zzzzzzz.
When will open source advocates learn to delegate the graphic design aspect of their work to professionals? Plenty of designers would be more than happy to contribute, if only the programming types in charge of these projects would admit they're better at making code than graphics.
With a general purpose language tied to a drawing library I can make custom graphics? Holy crap, who would have thought. For those of us who just want to generate some simple graphs for papers and such, what do people use? I've messed with Excel, gnuplot, R, and now I'm using ploticus. Anyone have better solutions?
Ah, the summary was so close to getting the words 'perl' and 'readable' in the same sentence (possibly for the first time), but just couldn't quite pull it off.
ccalam - acoustic versions of new songs.
... there's matplotlib and there's reportlab for PDFs. Both are excellent open source packages, and I can tell you from experience that reportlab has outstanding support. I recently posted a question to their mailing list and received three intelligent replies within an hour.
Nothing is being sold. The software is free. Should articles about Linux kernels and other OSS be tagged as you suggest?
I was looking for graphing and charting stuff last year. The only thing I found at the time was ChartDirector. There have been a couple of other open source ones posted above that I may investigate in future, but finding this was what I needed at the time.
Professor Karmadillo Songs of Science
...that pie charts are evil. However there are exceptions, like this one: http://themot.org/gallery/d/58721-1/pacmanchart.pn g. Most informative.
In case you missed the memo.
Using Perl to do an org chart?
Remember how programmers always talk about using the right tool for the right job?
If you want to do something like graphing, then why not learn a language like R, where you can easily and interactively create amazing visuals in very little time? I write code in Java, python, bash, and interact with Oracle and MySQL database. R fits in as a nice way to visualize data, and it's very easy to script up solutions that you can plug into your programming pipeline.
Check out http://addictedtor.free.fr/graphiques/index.php for examples (with source code)
With a general purpose language tied to a drawing library I can make custom graphics? Holy crap, who would have thought.
LibGD was made for this but does more now. There are lots of applications to do the same but "use libGD" is a good tip for people who want to make dynamic images and graphs for web pages from data.
For those of us who just want to generate some simple graphs for papers and such, what do people use? I've messed with Excel, gnuplot, R, and now I'm using ploticus.
gnuplot is very powerful. It has fitting with regression analysis, reports reduced chi squared and other math muscle stuff for papers all from text files.
Gnumeric is a good replacement for excel. It's resource light and the math is correct. It does simple graphs for papers and such.
DMCA, Hollings, Palladium. What might have sounded like paranoia is now common sense.
Or use Ruby with Gruff.
Vote Libertarian
I've been using Charts::* for my needs, these look much better. No functionality improvement, but looking better is sometimes a criteria.
It takes a man to suffer ignorance and smile
Be yourself no matter what they say
I make my PHP scripts output SVG. I feed it to ImageMagick's "convert", and then outputs it to the user.
Perl and GD. That's how charting is done in Bugzilla. Can't say it's superior, but it fits the needs. If I ever write something in Perl that would require charting then I might resort to GD.
For now, I'll avoid Perl if I can.
Every time you say "Goddammit!" when you try to run it? I gotta see what happens with this
What?
How can one create graphs and charts in html? I'd like to be able to do this for a web project I'm doing.
I did something like this over 3 year ago. It even use Apache and Mysql.
using Octave or SciLab.
Those charts look pretty hot to me. Did you look at the chart in the page? http://www-128.ibm.com/developerworks/opensource/l ibrary/os-perlgdchart/pie_step1_step2.gif :]
c tive_Pie_Chart.gif. odc_vststockallocation2003_fig03(en-us,office.11). gif
e fox
). Anti-aliased lines and text
Let's compare this to what I'd get if I asked most professionals for a chart. (These were the first ones from google). The lack of anti-aliasing hurts one's eye, these all look like they're from 1995.
http://support.alphasoftware.com/images/XD_Intera
http://msdn2.microsoft.com/en-us/library/aa192481
(the second one is 3d)
And in response to your comment
> When will open source advocates learn to delegate the graphic design aspect of their work to professionals? if only the programming types in charge of these projects would admit they're better at making code than graphics.
You seem to have missed the point. The article is about free software that can be used by professional and non-professional alike to create some hot graphics. Perhaps you're referring to the ugliness of the original tux logo? It's not 1995, and developers aren't resigned to producing their own graphics. If you look all free software houses pushing their brand use professional designers. Think of the firefox logo (2004)
http://www.hicksdesign.co.uk/journal/branding-fir
or of ubuntu and gnome's curves, and check out the tango project http://tango.freedesktop.org/
Desktop linux has never looked so sexy.
Why so sour, AC?
I think it's dual licensed, with a very modest fee for commercial use.
A year ago I went looking for code to draw Gantt like charts (for project scheduling, not the whole kebab).
I ended up rolling my own in GD with perl (making a wxPerl gui app). Reading this made me think (why doesn't he put it on CPAN) and then my next thought was (maybe I should put my own code up there before talking).
Not sure when I'll have time but anyway keep up the good work.
For everyone talking about design, yes it would not be a bad thing to take a first step to seeking designers interested in working on open source projects. Probably a bunch at every design department of a university and even high school maybe. Professionals may do it on their free time. Even choosing colors that go well is nice, and having a designer do a mockup of what they think it should look like might be enough for a programmer to grab on to.
It might be nice if there was an easier way to build charts (and yes I know JPGraph) but it seems you always want something custom in there, and only the person actually using it will know for sure if it is enough. Some more perl-based pluggable tools on CPAN for this would be a boon to a lot of people.
Incidentally I've done this before with driving the gimp from a perl program designed interactively with a readline-based gimp shell. It worked fabulously, and composited 1000 photos and as many html pages in about 5 minutes. But it was a one-off job. A simpler way to drive these tools (natural language based?) and get them configured would make them more accessible to people.
They're quite pretty in my opinion, but having read this thread, I realised they are not anti-aliased and that's not easy to do in GD::Graph at the moment (while drawing the lines, at least - I just read there is a trick one can do with resampling a 4x image).
Also, there's a problem with the lines not really being the desired thickness perpendicular to the direction of the line...
It was dead easy to get working though!
I do most of my work in Perl, and the lack of a good chart package has been annoying for a very long time. GD::Graph will give you very basic (and not terribly ugly) line and bar charts relatively quickly, but that's about it; it's missing even rudimentary features that make it less than useful (eg error bars).
There just isn't a general purpose charting package for Perl that would even come close to JFreeChart. Grace can produce some nice results, but the Perl interface to it is just a wrapper around their terrible command line interface (maybe it's improved in the last few years, but when I tried it it was almost entirely undocumented and nigh-unusable).
So, if you want publication quality charts you basically still have to learn gnuplot, which is great, but sometimes just a little too involved.
At least this thread gives a nice summary of what the other languages have to offer: the PHP and Ruby packages aren't faring any better, but Python's matplotlib looks freaking beautiful.
sic transit gloria mundi
Grace is an excellent free/open source 2D plotting program. It is in Motif, so some might call it "ugly," but I run it on Windows (it is packaged in cygwin), OS X, and linux. It is the most versatile F/OSS package I know of--both in terms of features & in terms of user interaction. In addition to the GUI (which many of the programs you list lack), you can use a command line interface or bindings for python, perl, fortran, C++, OCaml, octave, rlab, etc.
I miss the days when slashdot would post actual news. Using perl and GD is something you've been able to do for over a decade. What's next? News about how you can use zlib to compress stuff?
This place has become a pointless site where you can only read about point releases of the linux kernel and flamebaits of various kinds. And the saddest thing is those articles cause the most comments, thus the most revenue for slashdot, and thus this is what we will see more and more of from this website.
Judging by the examples, this brings the readability of Perl into graphs.
i echart/warning.en.html
I think I can hear Edward Tufte weeping...
And the only chart they implement is the pie chart:
http://www.usf.uni-osnabrueck.de/~breiter/tools/p
Xix.
"Everything is adjustable, provided you have the right tools"
We use R. I t produces visually appealing neat & clean graphics. My only bugbear is that the raster renders are external syscalls and often handle things like fonts and anti-aliasing poorly. We weer also looking at Rserv as a graphing service rather than invoking an R instance each time we want a graph. http://www.r-project.org/
Xix.
"Everything is adjustable, provided you have the right tools"
I used to use GD::Graph on my Windows-based system, but then the PPMs never got updated for the latest versions of ActivePerl.
For the longest time I have been without it since I updated ActivePerl, and there was no PPM available for GD::Graph on the ActiveState repository
http://ppm.activestate.com/BuildStatus/5.8-G.html
After looking at the site, I found the link at the bottom of this page that says you can install GD from Univ of Winnipeg, and I was able to install GD Graph from their repository.
If you really want the flashing lights, swirling thingies or generally make your charts management friendly, I'd recommend this library for PHP (or for Perl use the SWF::Chart wrapper).
:)
With enough animated transitions to last you a good 3-4 promotions you should be set
... and then there were none
Some of the open source JavaScript toolkits can be used to draw charts on a browser window with inline SVG and VML. This makes it possible to draw charts on the web browser instead of having the web server draw them.
Some examples:
Dojo Toolkit
I think I've seen a live charting demo on Dojo's official website, but it seems to be no longer there.
WT Toolkit
This one seems to be a new project, judging from the activity charts on their SourceForge page. The way they can draw 3D charts (like, pie charts, 3D bar charts) with inline SVG and VML is quite amazing though.
Wow, Perl and GD...that was big about 10 years ago. And the quality of the graphics produced by GD looks like something that belongs in the past.
Just some weeks ago I was looking for a way to make some plots. I usually use gnuplot but as far as I could see it seemed uanble to do bar plots, pie plots, discrete 3d plots (this is, make Z axxis a set of items instead of a continuos range), radar plots, bubble etc. It seems it is only possible to do point and line plots.
I looked for some tutorials on the web to do bar plots but they consisted in half assed hacks (translate the data point, surround it by a bounding box etc etc) which is too much work for something which should be quite trivial to do.
I ended using Excel to do my plots (I gave a try to Gnumeric, which has quite nice plotting tools, but they were unstable, specifically the area plots).
Ubuntu is an African word meaning 'I can't configure Debian'
It's scriptable, can do some calculations, does time series, has multiple outputs and is cross platfor.
My intro was on DOS plotting time series data to screen or an Epson MX80 printer.
I used Excel (4) which had serious issues with time series and Kaleidagraph on a Mac.
It's always there on Unix and I think there is/was a macintosh version.
gnuplot is timeless.
That said, for long term time series with thousands of data points, I like RRDtool. It deals well with consolidating the data.
[rant]I would be much more happy with AIX if they included a recent version of GD. As it stands, the version available for AIX 5.3 is so old it doesn't even have GIF support, and that makes a bunch of applications angry. Bugzilla for one doesn't like the version of GD that's available on AIX. I even tried compiling it myself, but ran into really weird font errors. Grrrr....sometimes I don't like AIX. [/rant]
KangarooBox - We make IT simple!