Slashdot Mirror


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."

2 of 112 comments (clear)

  1. Ah, charts in Perl... by glwtta · · Score: 4, Interesting

    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
  2. Re:wow! by Andy+Dodd · · Score: 4, Interesting

    octave + gnuplot + LaTeX = absolutely beautiful plots in anything I submitted (homework assignments, term papers) in grad school.

    To get you started (there could be errors here, I'm doing this from memory, but Octave code something similar to this:

    plot blah
    hold on
    plot something
    plot otherstuff
    hold off

    gset term postscript eps color 22
    gset output someplot.eps

    replot

    gset output foo %bad shit happens to your plot output if you don't change the output file when setting the term back to X11
    gset term x11

    Would do the following:
    Plot multiple things in a plot to the screen
    Output that plot to an EPS file
    Reset the output so the next plot would go back to the screen

    You could then run the .eps files through epstopdf, write some document in LaTeX that included your plots by their basename (i.e. without the .pdf extension in the document), and use pdflatex to generate a nice PDF file complete with clickable cross references

    (There are a lot of details I'm not mentioning here of course, unfortunately there really isn't any single good central HOWTO for doing all sorts of useful stuff in LaTeX.)

    --
    retrorocket.o not found, launch anyway?