Chart::XMGR - object for displaying data via XMGR


  use Chart::XMGR;

  xmgr($a, { SYMBOL => 'plus'};

  use Chart::XMGR ();

  $xmgr = new Chart::XMGR;


  xmgr($pdl, { LINESTYLE => 'dotted' });


Provides a perl/PDL interface to the XMGR plotting package. Can be used to plot PDLs or Perl arrays.

A simple function interface is provided that is based on the more complete object-oriented interface.

The interface can be implemented using either anonymous pipes or named pipes (governed by the module variable Chart::XMGR::NPIPE). If named pipes are used ($NPIPE = 1) XMGR can be controlled via the pipe and buttons are available for use in XMGR. If an anonymous pipe is used XMGR will not accept button events until the pipe has been closed.

Currently the named pipe option can not support data sets containing 3 or more columns (I haven't worked out how to do it anyway!). This means that only TYPE XY is supported. For anonymouse pipe 3 or more columns can be supplied along with the graph type.

The default option is to use the named pipe.


The following drawing options are available: The options are case-insensitive and minimum match.


Controls the linestyle. Allowed values are none(0), solid(1), dotted(2), dashed(3), dotdash(4). Default is solid.


Controls the line colour. LINECOLOR is an allowed synonym. Allowed values are white, black, red, green, blue, yellow, brown, gray, violet, cyan, magenta, orange, indigo, maroon, turqse and green4 (plus numeric equivalents: 0 to 15). Default is black.


Width of the line. Default is 1.


Governs whether the area inside the line is filled. Default is none.


Governs symbol type. 46 different types are supported (see XMGR options for the mapping to symbol type). Basic symbol types are available by name: none, dot, circle, square, diamond, triangleup, triangleleft, triangledown, triangleright, triangledown, triangleright, plus, X, star. Default is circle.


Colour of symbol. See LINECOLOUR for description of available values. Default is red.


Symbol size. Default is 1.


Governs whether symbols are filled (1), opaque (0) or have no fill (none(0)). Default is filled.


Set whether to autoscale as soon as set is drawn. Default is true.


Type of data set. Allowed values as for XMGR: XY, XYDX, XYDY, XYDXDX, XYDYDY, XYDXDY, XYZ, XYRT.


A simplified non-object oriented interface is provided. These routines are exported into the callers namespace by default.

xmgr( args, { options } )

A simplified interface to plotting on Xmgr.


Select the current set (integer 0->).


Detach XMGR from the pipe. This returns control of XMGR to the user.


Print arbritrary commands to XMGR. The @ symbol is prepended to all commands and a newline is appended.


The following methods are available.


Constructor. Is used to launch the new XMGR process and returns the object.


Return file handle (of type IO::Pipe) associated with external XMGR process.


Return options object associated with XMGR object.


Returns name of pipe associated with object.


Returns whether an XMGR process is currently attached to the object. Can also be used to set the state.


Returns (or sets) the current set.


Returns (or sets) the current graph.


Turns the debug flag on or off. If on (1) all commands sent to XMGR are also printed to STDOUT.

Default is false.


Method to prt Xmgr commands to the attached XMGR process. Carriage returns are appended. '@' symbols are prepended where necessary (needed for anonymous pipes, not for named pipes).

prt_data (data)

Print numbers to the pipe. No @ symbol is prepended. For named pipes we must use the POINT command. For anonymous pipes the data is just sent as is (so multiple column can be supplied).


Selects the current graph in XMGR.

plot($pdl, $pdl2, ..., $hash)

Method to plot XY data. Multiple arguments are allowed (in addition to the options hash). This routine plots the supplied data as the currently selected set on the current graph.

The interpretation of each input argument depends on the set type (specified as an option: SETTYPE). For example, 3 columns can be translated as XYDY, XYDX or XYZ. No check is made that the number of arguments matches the selected type.

Array references can be substituted for PDLs.

The options hash is assumed to be the last argument.

   $xmgr->plot(\@x, \@y, { LINECOL => 'red' } );

Process the options hash and send to XMGR. This sends the options for the current set.


Forces XMGR to redraw.


Kill a set. If no argument is specified the current set is killed; else the specified set (integer greater than or equal to 0) is killed.


Instruct XMGR to autoscale.


Autscale on the specified set (default to current set).

world(xmin, xmax, ymin, ymax)

Set the world coordinates.

viewport(xmin, xmax, ymin, ymax)

Set the current graphs viewport (where the current graphi is displayed).


Set the graphtype. Allowed values are: 'XY', 'BAR', 'HBAR', 'STACKEDBAR', 'STACKEDHBAR', 'LOGX', 'LOGY', 'LOGXY', 'POLAR', 'SMITH'


Configure the current set.

  $xmgr->configure(SYMBOL=>1, LINECOLOUR=>'red');

Close the pipe without asking XMGR to die. This can be used if you want to leave XMGR running after the object is destroyed. Note that no more messages can be sent to the XMGR process associated with this object.


Destructor for object. Sends the 'exit' message to the XMGR process. This will fail silently if the pipe is no longer open. (eg if the detach() method has been called.


An example program may look like this:

  use Chart::XMGR;
  use PDL;

  $a = pdl( 1,4,2,6,5);
  $xmgr = new Chart::XMGR;
  $xmgr->plot($a, { SYMBOL => 3, 
                    LINECOL => 'red', 
                    LINESTYLE => 2
                    SYMSIZE => 1 }

  $xmgr->configure(SYMCOL => 'green');

If PDL is not available, then arrays can be used:

  use Chart::XMGR
  @a = ( 1,4,2,6,5 );
  $xmgr = new Chart::XMGR;
  $xmgr->plot(\@a, { SYMBOL => 3, 
                    LINECOL => 'red', 
                    LINESTYLE => 2
                    SYMSIZE => 1 }

  $xmgr->configure(SYMCOL => 'green');

XMGR (Grace)

The XMGR home page is at This modules is designed to be used with XMGR version 4 (tested on v4.1.2). This module will probably not work with GRACE (XMGR version 5).


The PDL::Options module is required. This is available as part of the PDL distribution ( or separately in the PDL directory on CPAN.


For versions 0.90 and earlier this module was known by the name Graphics::XMGR (not on CPAN).


Copyright (C) Tim Jenness 1998,1999 ( All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.