Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

CGI modules for plotting & graphing

by ITmajor (Beadle)
on Jul 02, 2008 at 15:42 UTC ( #695143=perlquestion: print w/ replies, xml ) Need Help??
ITmajor has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys, does anyone know of any modules for cgi or perl that lets you plot graphs using text files? I also want to be able to save the file as an image (jpeg, gif, etc.) Any suggestions? I'm new to this so I'm looking for something that is easy to use and simple to understand.

Comment on CGI modules for plotting & graphing
Re: CGI modules for plotting & graphing
by jds17 (Pilgrim) on Jul 02, 2008 at 15:52 UTC
    Check out GD::Graph!

    Update: Sorry, I did not read your question with enough attention. GD::Graph is not based on simple text input for the graphics definition.

Re: CGI modules for plotting & graphing
by friedo (Prior) on Jul 02, 2008 at 15:55 UTC

    GD::Graph is excellent, and there's also Gnuplot. They both have lots of different types of graphs and styling options.

    Though not a Perl solution, I recently started using the really cool FusionCharts, which is a Flash widget that downloads data from your server (in XML) and renders really cool looking graphs client-side.

      Though not a Perl solution, I recently started using the really cool FusionCharts, which is a Flash widget that downloads data from your server (in XML) and renders really cool looking graphs client-side.

      There's XML/SWF Charts too, and it has a Perl interface!

      --
      David Serrano

Re: CGI modules for plotting & graphing
by pc88mxer (Vicar) on Jul 02, 2008 at 16:22 UTC
Re: CGI modules for plotting & graphing
by shoness (Friar) on Jul 02, 2008 at 20:37 UTC
    You might consider using the Google Chart API.

    The work is not entirely in your hands, and you obviously need "the internets", and it's not Perl. On the otherhand it's flexible, simple, and powerful.

    You just send the appropriate URL and get back a PNG image of your graph/chart/map/whatever.

Re: CGI modules for plotting & graphing
by moritz (Cardinal) on Jul 02, 2008 at 22:07 UTC
    Perl modules usually have a perl interface, but other programs often have text-only interface.

    The amazing program gnuplot has already been mentioned, but it's worth repeating. An alternative is grace, which is also a plotting utility that takes a plain text file as input. It also comes with xmgrace, a front end that generates these files.

Re: CGI modules for plotting & graphing
by starbolin (Hermit) on Jul 02, 2008 at 22:39 UTC

    The previous posters gave excellent input. Allow me to expand and enhance. I recently put quite a bit of time into understanding gnuplot. Be warned that the options available to you in a graphics window are different than those that are available when you print to a file. This, and the non-orthogonal arrangement of options, caused my quite a lot of consternation. I eventually decided gnuplot did not suit my data set so I ended up switching back to GD and it's offspring. Now I'm much happier.

    I case you wind up going that route, here is a perl script to launch gnuplot and feed it a list of commands. The commands generate a png file.

    #!/usr/bin/perl # # ptoplot.pl # use strict; use warnings; my $output_file = "graphics/plot1"; my $cmd = '| gnuplot - 2>&1'; open PLOT, "$cmd" or die; while (<DATA>) { print PLOT "$_"; } qx("sync"); __DATA__ set terminal png medium color picsize 800 600 set output "graphics/plot1" set title 'Splot of file plot.dat' set style data dots # set hidden3d # set data palette set contour base set zlabel 'amplitude' splot "graphics/plot.dat" matrix with lines show output


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://695143]
Approved by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-11-28 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (194 votes), past polls