I've spent a lot of frustrating time trying to find the 'best' way to create pretty graphics from data in my perl programs.

Spent a lot of time with GD.pm, it has a lot of easy-to-use modules built around it, but the graphics are always strongly aliased. There are tricks to lessen the aliasing, but nothing is perfect: Always a lot of hassle, no matter how much tweaking you do.

At one point, I looked at using POV-Ray files. POV-Ray graphing example Generating the text format file in perl, then doing a not-so-quick system call to ask POV-Ray to render the image for me. This was slow and 3-d only works for a limited range of information graphics.

I'm writing this because I'm bursting at the seams with excitement because I HAVE FOUND THE ANSWER: generating SVG files and using ImageMagik to convert those into whatever else you want (png,jpg,pdf,etc). SVG uses XML files and the syntax isn't overly weird. I started out using a WYSIWYG vector graphic program that exports SVG code http://www.sodipodi.com/, then manipulating the code in perl to produce what I was looking for. Mind you, as with most WYSIWYG's, I was able to reduce the auto-generated code by over 80%. But I learn better by having an example and tweaking it.

To introduce you to the joys of this format, if you are unfamiliar with it; here's an example graphic produced by running a perl-generated svg file through convert via a system call: http://www.oakbox.com/svg2png.png

And here is the svg file: http://www.oakbox.com/svg2png.svg.

And I get all this goodness by running
 system(convert svg2png.svg svg2png.png);

So, to sum up:
SVG + ImageMagick = Happiness


In reply to Pretty graphics generation by oakbox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.