NAME
Chart::XMGR - object for displaying data via XMGR
SYNOPSIS
use Chart::XMGR;
xmgr($a, { SYMBOL => 'plus'};
use Chart::XMGR ();
$xmgr = new Chart::XMGR;
$xmgr->line($pdl);
$pdl->$xmgr->line;
xmgr($pdl, { LINESTYLE => 'dotted' });
DESCRIPTION
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.
OPTIONS
The following drawing options are available: The options are case-insensitive and minimum match.
- LINESTYLE
-
Controls the linestyle. Allowed values are none(0), solid(1), dotted(2), dashed(3), dotdash(4). Default is solid.
- LINECOLOUR
-
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.
- LINEWIDTH
-
Width of the line. Default is 1.
- FILL
-
Governs whether the area inside the line is filled. Default is none.
- SYMBOL
-
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.
- SYMCOLOUR
-
Colour of symbol. See LINECOLOUR for description of available values. Default is red.
- SYMSIZE
-
Symbol size. Default is 1.
- SYMFILL
-
Governs whether symbols are filled (1), opaque (0) or have no fill (none(0)). Default is filled.
- AUTOSCALE
-
Set whether to autoscale as soon as set is drawn. Default is true.
- SETTYPE
-
Type of data set. Allowed values as for XMGR: XY, XYDX, XYDY, XYDXDX, XYDYDY, XYDXDY, XYZ, XYRT.
NON-OO INTERFACE
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.
- xmgrset(set)
-
Select the current set (integer 0->).
- xmgrdetach
-
Detach XMGR from the pipe. This returns control of XMGR to the user.
- xmgrprint(string)
-
Print arbritrary commands to XMGR. The @ symbol is prepended to all commands and a newline is appended.
METHODS
The following methods are available.
- new()
-
Constructor. Is used to launch the new XMGR process and returns the object.
- pipe
-
Return file handle (of type IO::Pipe) associated with external XMGR process.
- opt()
-
Return options object associated with XMGR object.
- npipe()
-
Returns name of pipe associated with object.
- attached()
-
Returns whether an XMGR process is currently attached to the object. Can also be used to set the state.
- set()
-
Returns (or sets) the current set.
- graph()
-
Returns (or sets) the current graph.
- debug()
-
Turns the debug flag on or off. If on (1) all commands sent to XMGR are also printed to STDOUT.
Default is false.
- prt(text)
-
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).
- select_graph
-
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' } ); $xmgr->plot($pdl);
- send_options(hashref)
-
Process the options hash and send to XMGR. This sends the options for the current set.
- redraw()
-
Forces XMGR to redraw.
- killset([setnum])
-
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.
- autoscale()
-
Instruct XMGR to autoscale.
- autoscale_on([set])
-
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).
- graphtype(type)
-
Set the graphtype. Allowed values are: 'XY', 'BAR', 'HBAR', 'STACKEDBAR', 'STACKEDHBAR', 'LOGX', 'LOGY', 'LOGXY', 'POLAR', 'SMITH'
- configure(hash)
-
Configure the current set.
$xmgr->configure(SYMBOL=>1, LINECOLOUR=>'red');
- detach()
-
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.
- DESTROY
-
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.
EXAMPLE
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');
$xmgr->detach;
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->detach;
XMGR (Grace)
The XMGR home page is at http://plasma-gate.weizmann.ac.il/Xmgr/ 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).
REQUIREMENTS
The PDL::Options module is required. This is available as part of the PDL distribution (http://pdl.perl.org) or separately in the PDL directory on CPAN.
NOTES
For versions 0.90 and earlier this module was known by the name Graphics::XMGR (not on CPAN).
AUTHOR
Copyright (C) Tim Jenness 1998,1999 (t.jenness@jach.hawaii.edu). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.