Tim Jenness > Chart-GRACE-0.95 > Chart::GRACE

Download:
Chart-GRACE-0.95.tar.gz

Dependencies

Annotate this POD

Related Modules

Image::Magick
Inline::Java
GD::Graph
more...
By perlmonks.org

CPAN RT

New  2
Open  0
View/Report Bugs
Module Version: 0.95   Source  

NAME ^

Chart::GRACE - object for displaying data via Xmgrace

SYNOPSIS ^

  use Chart::GRACE;

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

  use Chart::GRACE ();

  $grace = new Chart::GRACE;
  $grace->plot($pdl);

  xmgrace($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::GRACE::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 have not 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.

xmgrace( args, { options } )

A simplified interface to plotting on Xmgrace.

xmgraceset(set)

Select the current set (integer 0->).

xmgracedetach

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

xmgraceprint(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 XMGRACE process.

opt()

Return options object associated with XMGRACE object.

npipe()

Returns name of pipe associated with object.

attached()

Returns whether an XMGRACE 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 XMGRACE are also printed to STDOUT.

Default is false.

prt(text)

Method to print Xmgrace commands to the attached XMGRACE 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 XMGRACE.

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 XMGRACE. This sends the options for the current set.

redraw()

Forces XMGRACE 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 XMGRACE 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 XMGRACE to die. This can be used if you want to leave XMGRACE running after the object is destroyed. Note that no more messages can be sent to the XMGRACE process associated with this object.

DESTROY

Destructor for object. Sends the 'exit' message to the XMGRACE 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::GRACE;
  use PDL;

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

  $xmgrace->configure(SYMCOL => 'green');
  $xmgrace->detach;

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

  use Chart::GRACE

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

  $xmgrace->configure(SYMCOL => 'green');
  $xmgrace->detach;

GRACE ^

The GRACE home page is at http://plasma-gate.weizmann.ac.il/Grace/ This modules is designed to be used with XMGRACE version 5.1.1.

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 or my author directory.

SEE ALSO ^

Chart::XMGR

HISTORY ^

This module was derived from Chart::XMGR

AUTHOR ^

Copyright (C) Tim Jenness 1998,1999,2001 <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.

syntax highlighting: