The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Chart::Graph - Perl extension for a front-end to gnuplot, XRT, and Xmgrace.


 # EXAMPLE: gnuplot
 #make sure to include Chart::Graph
 use Chart::Graph:Gnuplot qw(gnuplot);

 gnuplot(\%global_options, [\%data_set_options, \@matrix],
                           [\%data_set_options, \@x_column, \@y_column],
                           [\%data_set_options, < filename >], ... );

 # EXAMPLE: Xmgrace
 #make sure to include Chart::Graph
 use Chart::Graph::Xmgrace qw(xmgrace);
 xmgrace(\%global_options, [\%data_set_options, \@matrix],
                           [\%data_set_options, \@x_column, \@y_column],
                           [\%data_set_options, < filename >], ... );

 # EXAMPLE: xrt2d
 #make sure to include Chart::Graph
 use Chart::Graph::Xrt2d qw(xrt2d);

 xrt2d(\%options, \@data_set);

 #say for example we have a 3 by 4 matrix -> dataxy
       [[data11, data12, data13, data14],
       [data21, data22, data23, data24],
       [data31, data32, data33, data34]])

 # EXAMPLE: xrt3d
 #make sure to include Chart::Graph
 use Chart::Graph::Xrt3d qw(xrt3d);

 xrt3d(\%options, \@data_set);

 #say for example we have a 3 by 4 matrix -> dataxy
       [[data11, data12, data13, data14],
       [data21, data22, data23, data24],
       [data31, data32, data33, data34]])


 use Chart::Graph; is a wrapper module that allows easy generation of graphs within perl. Currently supports three graphing packages, gnuplot, XRT, and Xmgrace. These software packages must be obtained separately from this Perl module. Information on each graphing package and it's availability is provided in the documentation on that module. Gnuplot and Xmgrace are freely available software pages for UNIX systems. XRT is a commercial product.

Currently the xrt3d and xrt2d package is not being supported, although it works. It is still in the development stage. Feel free to give it a try though.


Because Chart-Graph is a wrapper script, you need to install the graphic package that you wish to use before attempting to install Unless the appropriate graphics software is installed, the testing portions of the install will fail.

If you want to use the xrt2d/xrt3d package, you need to build the respective "graph" binaries in the xrt2d/xrt3d directories. Refer to the README files in the xrt2d and xrt3d directories for instructions on creating the required binaries. use the standard Perl module installation procedure. To install on your system you need to run:

         perl Makefile.PL
         make test
         make install

The standard Perl options apply. For example you can specify the location of you Perl Installation by the option: PREFIX=/home/your/private/dir. Which results modifying the first command as follows:

         perl Makefile.PL PREFIX=/your/private/dir

Running the Makefile.PL Perl script mades some additional preparation before creating the the Makefile. In particular, the script sets up the testing routines for the various graphics modules.

        Enter (space separated) graphing drivers to test: [gnuplot xrt3d xrt2d xmgrace]

Enter the names of the graphical software packages that you have installed. The others will be ignored even if Chart-Graph will appear to "test" them. If you are using Xmgrace or XRT there are additional options you will need to supply. In order to permit Xmgrace to perform its test without using the X server you should provide a path to a X virtual frame buffer.

        Enter path to X virtual frame buffer(Xvfb):

Finally, If you are running XRT, you need to provide that path to the XRT binaries:

        Enter path to xrt2d binary (built from xrt2d/):

Note that running the tests will create image files that are placed in the directory test_results. These images are almost all identical with the examples provided with the documentation and can be used to check if there are subtile errors in your image creation software.


Chart::Graph attempts as much as possible to provide a uniform interface to these different graphics packages. Unfortunately, the functionality of each program is sufficiently different that the interface cannot be entirely uniform.


Currently Chart::Graph supports two levels of debug, 0 (no debug msgs) and 1(debug msgs). You need to set the $Chart::Graph::debug flag accordingly. If you are having problems with set the debug flag to 1. Also will check $ENV{TMPDIR} for the temporary file storage. If you do not specify, it will be set to /tmp automatically. Temporary files can also be saved for further debugging purposes by setting $Chart::Graph::save_tmpfiles flag accordingly, 0 (no tmp files saved) or 1 (save tmp files specified in $ENV{TMPDIR) or /tmp by default)

Note: Currently, XRT and Xmgrace use the local x server to draw it's graphics by default. With XRT, if you are having problems with color or speed is an issue, set $Chart::Graph::use_xvbf to 1 to use the virtual x frame buffer. With Xmgrace, you MUST set $Chart::Graph::use_xvbf to 1 if you are not using a local x server.

All the documentation is also provided in HTML with the sample graphic files for are located in the doc directory.

CONTENT SUMMARY        - top level file of Chart::Graph
 Graph/          - sub modules of Chart::Graph
 Graph/Xmgrace/  - sub modules of Chart::Graph::Xmgrace
 doc/            - documentation in HTML 
 xrt2d/          - xrt2d wrapper executable code
 xrt3d/          - xrt3d wrapper executable code   - the test script used for debugging


For more information on gnuplot, please see the gnuplot web page:

For more information on Xmgrace, please see the Xmgrace web page:

For more information on XRT, please contact Sitraka (now Quest):


Send email to is you have problems, questions, or comments. To subscribe to the mailing list send mail to with a body of "subscribe"


 CAIDA Perl development team (