How can you use Perl plotting through the "gnuplot" drawing charts variant



In order to use Perl Plotting and graphics you can find several different modules on the net.

Generally speaking, you have at least 2 great opportunities: code everything in Perl using one of the CPAN available modules or use some other plotting programs, called externally from a Perl script.

In your decision you must take in consideration the application specific you have to develop and the types of chart (2-D or 3-D plotting and rendering) you want to implement.

Next, I am going to present to you the “gnuplot” drawing charts variant.


Click Below to See the Best

Perl How-to Snippet Collection

and Save Hours of Surfing on Internet!


1. The gnuplot plotting utility

gnuplot is an interactive plotting program and can be used to render charts both in 2-D or 3-D dimensions, in many different formats. It is an external program and you can talk to it using a module interface (see below).

It’s available for UNIX, IBM OS/2, MS Windows, DOS, Macintosh, VMS, Atari and many other platforms. Though it is copyrighted – you can freely distribute it on the condition not to modify it.

And now, if you are curious about and you want to get and try it, please use the link below in order to download the current released version:

gnuplot for Perl plotting

From the same page you can browse through other useful links such as FAQ, Demos, Tutorials, etc.

You can:

  • draw chart of many types: lines, pointx, bars, contours, surfaces, stacked histograms
  • draw text on the chart
  • use multiple pages on one page
  • use multiple axes on a single plot
  • output many types of file(jpeg, pbm, pdf, png, gif, …)
  • animate your graphs

and a lot of other features which you can find on the page you can access through the link presented above.

In order to use this plotting program in Perl, you must download Graphics-GnuplotIF module which represents a dynamic Perl interface to gnuplot and can be got by accessing the page: "http://search.cpan.org/~mehner/Graphics-GnuplotIF-1.4/"

This module allows you send requests to gnuplot through simple Perl subroutine calls. The gnuplot program is launched as a separate process, the plot commands being sending through a pipe (be sure that the operating system you are using supports pipes) . You can start several independent plots from one script, each plot having its own pipe.


2. The Chart::Graph module and Gnuplot() function.

Another available opportunity for Perl plotting, is to use the function gnuplot() of the Chart::Graph module, which is a Perl extension for a front-end to gnuplot, XRT, and Xmgrace.

The function gnuplot() can be used with almost the same options and arguments as the gnuplot application itself (see point 1. above). You can download this module by accessing the page: "http://psb.sbras.ru/docs/CPAN/pub/CPAN/modules/by-module/ Chart/Chart-Graph-3.2.tar.gz"

For more information about how you can use the function gnuplot(), please see the page link:

"http://perl.asylog.net/perl5.6.1/site_perl/5.6.1/Chart/Graph/Gnuplot.html"

A-N-Y-O-N-E Can Learn and Master Perl!
And That Includes YOU!


Check these how-to tutorial eBooks (PDF format):


Related links:

Perl ZIP File

Perl Plotting

Image Magick Perl

PDF Perl

return from Perl Modules to Home Page