1Window(3)             User Contributed Perl Documentation            Window(3)
2
3
4

NAME

6       PDL::Graphics::PGPLOT::Window - A OO interface to PGPLOT windows
7

SYNOPSIS

9        perldl> use PDL::Graphics::PGPLOT::Window
10        perldl> $win = pgwin(Device => '/xs');
11        perldl> $a = pdl [1..100]
12        perldl> $b = sqrt($a)
13        perldl> $win->line($b)
14        perldl> $win->hold()
15        perldl> $c = sin($a/10)*2 + 4
16        perldl> $win->line($c)
17
18       In the following documentation the commands are not shown in their OO
19       versions. This is for historical reasons and should not cause too much
20       trouble.
21

DESCRIPTION

23       This package offers a OO interface to the PGPLOT plotting package. This
24       is intended to replace the traditional interface in
25       PDL::Graphics::PGPLOT and contains interfaces to a large number of
26       PGPLOT routines. Below the usage examples for each function tend to be
27       given in the non-OO version for historical reasons. This will slowly be
28       changed, but in the meantime refer to the section on OO-interface below
29       to see how to convert the usage information below to OO usage (it is
30       totally trivial).
31
32       PDL::Graphics::PGPLOT::Window is an interface to the PGPLOT graphical
33       libraries.  It currently supports PGPLOT-5.2 and PGPLOT-5.2-cd2.  The
34       -cd2 version includes RGB output and anti-aliasing.
35
36       High-level plotting commands:
37
38        imag       -  Display an image (uses pgimag/pggray/pgrgbi as appropriate)
39        fits_imag  -  Display a FITS image in scientific coordinates
40        cont       -  Display image as contour map
41        fits_cont  -  Display a FITS image in scientific coordinates as a contour map
42        vect       -  Display 2 images as a vector field
43        fits_vect  -  Display 2 FITS images in sci. coordinates as a vector field
44        ctab       -  Load an image colour table
45        ctab_info  -  Get information about currently loaded colour table
46        line       -  Plot vector as connected points
47        tline      -  Plot a collection of vectors as lines
48        lines      -  Plot a polyline, multicolor vector [threadable]
49        points     -  Plot vector as points
50        tpoints    -  Plot a collection of vectors as points [threadable]
51        errb       -  Plot error bars
52        bin        -  Plot vector as histogram (e.g. bin(hist($data)) )
53        hi2d       -  Plot image as 2d histogram (not very good IMHO...)
54        tcircle    -  Plot vectors as circles [threadable]
55        label_axes -  Print axis titles
56        legend     -  Create a legend with different texts, linestyles etc.
57
58       Low-level plotting commands:
59
60        arrow      -  Draw an arrow
61        poly       -  Draw a polygon
62        rectangle  -  Draw a rectangle
63        text       -  Write text in the plot area
64        cursor     -  Interactively read cursor positions.
65        circle     -  Draw a circle
66        ellipse    -  Draw an ellipse.
67
68       Device manipulation commands:
69
70        new           -  Construct a new output device
71        pgwin         -  Exported hook to new()
72        close         -  Close a PGPLOT output device.
73        hold          -  Hold current plot window range - allows overlays etc.
74        release       -  Release back to freshly autoscaling for each command.
75        held          -  Indicates whether the current window is held.
76        focus         -  Set focus to the given device.
77        erase         -  Erase the current window (or panel).
78        options       -  Get the options set for the present output device.
79        id            -  The ID for the device.
80        device        -  The device type.
81        name          -  The window name.
82
83       Notes: $transform for image/cont etc. is used in the same way as the
84       "TR()" array in the underlying PGPLOT FORTRAN routine but is,
85       fortunately, zero-offset. The transform() routine can be used to create
86       this piddle.
87
88       For completeness: The transformation array connect the pixel index to a
89       world coordinate such that:
90
91        X = tr[0] + tr[1]*i + tr[2]*j
92        Y = tr[3] + tr[4]*i + tr[5]*j
93
94   Variable passing and extensions
95       In general variables are passed to the pgplot routines by using
96       "get_dataref" to get the reference to the values. Before passing to
97       pgplot routines however, the data are checked to see if they are in
98       accordance with the format (typically dimensionality) required by the
99       PGPLOT routines.  This is done using the routine "checkarg" (internal
100       to PGPLOT). This routine checks the dimensionality of the input data.
101       If there are superfluous dimensions of size 1 they will be trimmed away
102       until the dimensionality is correct. Example:
103
104       Assume a piddle with dimensions (1,100,1,1) is passed to "line", which
105       expects its inputs to be vectors. "checkarg" will then return a piddle
106       with dimensions (100). If instead the same piddle was passed to "imag",
107       which requires 2D piddles as output, "checkarg" would return a piddle
108       with dimensionality (100, 1) (Dimensions are removed from the start)
109
110       Thus, if you want to provide support for another PGPLOT function, the
111       structure currently look like this (there are plans to use the Options
112       package to simplify the options parsing):
113
114        # Extract the hash(es) on the commandline
115        ($arg, $opt)=_extract_hash(@_);
116        <Check the number of input parameters>
117        <deal with $arg>
118        checkarg($x, 3); # For a hypothetical 3D routine.
119        &catch_signals;
120        ...
121        pgcube($n, $x->get_dataref);
122        &release_signals;
123        1;
124
125       (the catch_signals/release_signals pair prevent problems with the perl-
126       PGPLOT interface if the user hits c-C during an operation).
127
128   Setting options
129       All routines in this package take a hash with options as an optional
130       input. This options hash can be used to set parameters for the
131       subsequent plotting without going via the PGPLOT commands.
132
133       This is implemented such that the plotting settings (such as line
134       width, line style etc.) are affected only for that plot, any global
135       changes made, say, with "pgslw()" are preserved. Some modifications
136       apply when using the OO interface, see below.
137
138   Alphabetical listing of standard options
139       The following options are always parsed. Whether they have any
140       importance depend on the routine invoked - e.g. line style is
141       irrelevant for "imag", or the "justify" option is irrelevant if the
142       display is on 'hold'.  This is indicated in the help text for the
143       commands below.
144
145       The options are not case sensitive and will match for unique
146       substrings, but this is not encouraged as obscure options might
147       invalidate what you thought was a unique substring.
148
149       In the listing below examples are given of each option. The actual
150       option can then be used in a plot command by specifying it as an
151       argument to the function wanted (it can be placed anywhere in the
152       command list).
153
154       E.g:
155
156        $opt={COLOR=>2};
157        line $x, $y, $opt; # This will plot a line with red color
158
159       If you are plotting to a hardcopy device then a number of options use a
160       different name:
161
162         HardLW   instead of LineWidth
163         HardCH   instead of CharSize
164         HardFont instead of Font
165
166         HardAxisColour instead of AxisColour
167         HardColour     instead of Colour
168
169       [although I'm not sure when HardColour is actually used]
170
171       align
172           If "pix" is set, then images and plots are not stretched to fill
173           the plot area.  the "align" string tells how to align them within
174           the available area.  'L' and 'R' shove the plot against the left
175           and right edges, respectively; 'B' and 'T' shove the plot against
176           the bottom and top edges.  The default is to center the image.
177           e.g. 'BL' puts the image on the bottom left corner, while 'CT'
178           centers the image horizontally while placing it at the top of the
179           available plot area.  This defaults to 'BT' for non-justified
180           images, to 'CC' for justified images.
181
182       arrow
183           This options allows you to set the arrow shape, and optionally size
184           for arrows for the vect routine. The arrow shape is specified as a
185           hash with the key FS to set fill style, ANGLE to set the opening
186           angle of the arrow head, VENT to set how much of the arrow head is
187           cut out and SIZE to set the arrowsize.
188
189           The following
190
191            $opt = {ARROW => {FS=>1, ANGLE=>60, VENT=>0.3, SIZE=>5}};
192
193           will make a broad arrow of five times the normal size.
194
195           Alternatively the arrow can be specified as a set of numbers
196           corresponding to an extention to the syntax for pgsah. The
197           equivalent to the above is
198
199            $opt = {ARROW => pdl([1, 60, 0.3, 5})};
200
201           For the latter the arguments must be in the given order, and if any
202           are not given the default values of 1, 45, 0.3 and 1.0 respectively
203           will be used.
204
205       arrowsize
206           The arrowsize can be specified separately using this option to the
207           options hash. It is useful if an arrowstyle has been set up and one
208           wants to plot the same arrow with several sizes. Please note that
209           it is not possible to set arrowsize and character size in the same
210           call to a plotting function. This should not be a problem in most
211           cases.
212
213            $opt = {ARROWSIZE => 2.5};
214
215       axis
216           Set the axis value (see "env").  If you pass in a scalar you set
217           the axis for the whole plot.  You can also pass in an array ref for
218           finer control of the axes.
219
220           If you set the option to a scalar value, you get one of a few
221           standard layouts.  You can specify them by name or by number:
222
223            EMPTY  (-2) draw no box, axes or labels
224            BOX    (-1) draw box only
225            NORMAL (0)  draw box and label it with coordinates
226            AXES   (1)  same as NORMAL, but also draw (X=0,Y=0) axes
227            GRID   (2)  same as AXES, but also draw grid lines
228            LOGX   (10) draw box and label X-axis logarithmically
229            LOGY   (20) draw box and label Y-axis logarithmically
230            LOGXY  (30) draw box and label both axes logarithmically
231
232           When using logarithmic axes ("LOGX", "LOGY" and "LOGXY") you
233           normally need to log the data yourself, e.g.
234
235             line $x->log10, $y, {axis=>'LOGX'};
236
237           For your convenience you can put PDL::Graphics::PGPLOT into autolog
238           mode. In this mode a call to "line" or "points" will log the data
239           for you and you can pass in the unmodified data, e.g.
240
241             autolog(1); # enable automatic logarithm calculation
242             line $x, $y, {axis=>'LOGX'}; # automatically displays logged x data
243
244           You can use the function interface to enable autologging:
245
246             autolog(1);
247
248           or use it with a window reference (mode switching on a per window
249           basis)
250
251             $win->autolog(1);
252
253           "autolog" without arguments returns the current autolog setting
254           (0=off, 1=on).
255
256           If you set the "AXIS" option to an array ref, then you can specify
257           the box/axis options separately for the horizontal (ordinate; X
258           coordinate; 0th element) and vertical (abscissa; Y coordinate; 1st
259           element)) axes.  Each element of the array ref should contain a
260           PGPLOT format string.  Presence or absence of specific characters
261           flags particular options.  For normal numeric labels, the options
262           are:
263
264             A : draw axis for this dimension.
265             B : draw bottom (X) or left (Y) edge of frame.
266             C : draw top (X) or right (Y) edge of frame.
267             G : draw Grid of vertical (X) or horizontal (Y) lines.
268             I : Invert ticks: draw them outside the plot rather than inside.
269             L : Label the axis Logarithmically.
270             P : Extend ("Project") major tick marks outside the box.
271             M : Numeric labels go in the alternate place above (X) or to the
272                      right (Y) of the viewport.
273             N : Numeric labels go in the usual location below (X) or to the
274                      left  (Y) of the viewport
275             T : Draw major tick marks at the major coordinate interval.
276             S : Draw minor tick marks (subticks).
277             V : Orient numeric labels Vertically.  Only applicable to Y.
278                      (The default is to write them parallel to the axis.)
279             1 : Force decimal labelling, instead of automatic choice
280             2 : Force exponential labeling, instead of automatic.
281
282           If you don't specify any axis value at all, the default is
283           ['BCNST','BCNST'] for plots and ['BCINST','BCINST'] for images.
284           (These list ref elements are handed on directly to the low-level
285           PGPLOT routines).
286
287           In addition, you can specify that your axis labels should be
288           printed as days, hours, minutes, and seconds (ideal for julian
289           dates and delta-t, or for angular quantities).  You do that by
290           setting additional character flags on the affected axis:
291
292             X : Use HH MM SS.S time labeling rather than conventional numeric
293                 labels.  The ordinate is in secsonds. Hours roll over at 24.
294             Y : Like 'X' but the hour field runs past 24 if necessary.
295             Z : Like 'X' but with a days field too (only shown where nonzero).
296             H : Label the numbers with superscript d, h, m, and s symbols.
297             D : Label the numbers with superscript o, ', and '' symbols.
298             F : Omit first (lowest/leftmost) label; useful for tight layouts.
299             O : Omit leading zeroes in numbers under 10 (e.g. " 3h 3m 1.2s"
300                 rather than "03h 03m 01.2s").
301
302           For example, to plot a numeric quantity versus Julian day of the
303           year in a standard boxed plot with tick marks, you can use
304           ["BNCSTZHO","BCNST"].
305
306       border
307           Normally the limits are chosen so that the plot just fits; with
308           this option you can increase (or decrease) the limits by either a
309           relative (ie a fraction of the original axis width) or an absolute
310           amount.  Either specify a hash array, where the keys are "TYPE"
311           (set to 'relative' or 'absolute') and "VALUE" (the amount to change
312           the limits by), or set to 1, which is equivalent to
313
314            BORDER => { TYPE => 'rel', VALUE => 0.05 }
315
316       charsize
317           Set the character/symbol size as a multiple of the standard size.
318
319            $opt = {CHARSIZE => 1.5}
320
321           The HardCH option should be used if you are plotting to a hardcopy
322           device.
323
324       colour (or color)
325           Set the colour to be used for the subsequent plotting. This can be
326           specified as a number, and the most used colours can also be
327           specified with name, according to the following table (note that
328           this only works for the default colour map):
329
330             0 - WHITE    1 - BLACK     2 - RED      3 - GREEN    4 - BLUE
331             5 - CYAN     6 - MAGENTA   7 - YELLOW   8 - ORANGE  14 - DARKGRAY
332            16 - LIGHTGRAY
333
334           However there is a much more flexible mechanism to deal with
335           colour.  The colour can be set as a 3 or 4 element anonymous array
336           (or piddle) which gives the RGB colours. If the array has four
337           elements the first element is taken to be the colour index to
338           change. For normal work you might want to simply use a 3 element
339           array with R, G and B values and let the package deal with the
340           details. The R,G and B values go from 0 to 1.
341
342           In addition the package will also try to interpret non-recognised
343           colour names using the default X11 lookup table, normally using the
344           "rgb.txt" that came with PGPLOT.
345
346           For more details on the handling of colour it is best that the user
347           consults the PGPLOT documentation. Further details on the handling
348           of colour can be found in the documentation for the internal
349           routine "_set_colour".
350
351           The HardColour option should be used if you are plotting to a
352           hardcopy device [this may be untrue?].
353
354       diraxis
355           This sets the direction of the axes of a plot or image, when you
356           don't explitly set them with the XRange and YRange options.  It's
357           particularly useful when you want (for example) to put long
358           wavelengths (larger numbers) on the left hand side of your plot, or
359           when you want to plot an image in (RA,dec) coordinates.
360
361           You can use either a scalar or a two-element perl array.  If you
362           set it to 0 (the default) then PDL will guess which direction you
363           want to go.  If you set it to a positive number, the axis will
364           always increase to the right. If you set it to a negative number,
365           the axis will always increase to the left.
366
367           For example, [0,0] is the default, which is usually right.  [1,1]
368           tells PGPLOT to always increase the axis values up and to the
369           right.  For a plot of intensity (y-axis) versus wavelength (x-axis)
370           you could say [-1,1].
371
372           This option is really only useful if you want to allow autoranging
373           but need to set the direction that the axis goes.  If you use the
374           ranging options ("XRange" and "YRange"), you can change the
375           direction by changing the order of the maximum and minimum values.
376           That direction will override "DirAxis".
377
378       filltype
379           Set the fill type to be used by "poly", "circle", "ellipse", and
380           "rectangle" The fill can either be specified using numbers or name,
381           according to the following table, where the recognised name is
382           shown in capitals - it is case-insensitive, but the whole name must
383           be specified.
384
385            1 - SOLID
386            2 - OUTLINE
387            3 - HATCHED
388            4 - CROSS_HATCHED
389
390            $opt = {FILLTYPE => 'SOLID'};
391
392           (see below for an example of hatched fill)
393
394       font
395           Set the character font. This can either be specified as a number
396           following the PGPLOT numbering or name as follows (name in
397           capitals):
398
399            1 - NORMAL
400            2 - ROMAN
401            3 - ITALIC
402            4 - SCRIPT
403
404           (Note that in a string, the font can be changed using the escape
405           sequences "\fn", "\fr", "\fi" and "\fs" respectively)
406
407            $opt = {FONT => 'ROMAN'};
408
409           gives the same result as
410
411            $opt = {FONT => 2};
412
413           The HardFont option should be used if you are plotting to a
414           hardcopy device.
415
416       hatching
417           Set the hatching to be used if either fillstyle 3 or 4 is selected
418           (see above) The specification is similar to the one for specifying
419           arrows.  The arguments for the hatching is either given using a
420           hash with the key ANGLE to set the angle that the hatch lines will
421           make with the horizontal, SEPARATION to set the spacing of the
422           hatch lines in units of 1% of "min(height, width)" of the view
423           surface, and PHASE to set the offset the hatching. Alternatively
424           this can be specified as a 1x3 piddle "$hatch=pdl[$angle, $sep,
425           $phase]".
426
427            $opt = {FILLTYPE => 'HATCHED',
428                    HATCHING => {ANGLE=>30, SEPARATION=>4}};
429
430           Can also be specified as
431
432            $opt = {FILL=> 'HATCHED', HATCH => pdl [30,4,0.0]};
433
434           For another example of hatching, see "poly".
435
436       justify
437           If "justify" is set true, then the plot axes are shrunk to fit the
438           plot or image and it specifies the aspect ratio of pixel
439           coordinates in the plot or image.  Setting justify=>1 will produce
440           a correct-aspect-ratio, shrink-wrapped image or plot; setting
441           justify=>0.5 will do the same thing but with a short and fat plot.
442           The difference between "justify" and "pix" is that "pix" does not
443           affect the shape of the axes themselves.
444
445       linestyle
446           Set the line style. This can either be specified as a number
447           following the PGPLOT numbering:
448
449            1 - SOLID line
450            2 - DASHED
451            3 - DOT-DASH-dot-dash
452            4 - DOTTED
453            5 - DASH-DOT-DOT-dot
454
455           or using name (as given in capitals above).  Thus the following two
456           specifications both specify the line to be dotted:
457
458            $opt = {LINESTYLE => 4};
459            $varopt = {LINESTYLE => 'DOTTED'};
460
461           The names are not case sensitive, but the full name is required.
462
463       linewidth
464           Set the line width. It is specified as a integer multiple of 0.13
465           mm.
466
467            $opt = {LINEWIDTH => 10}; # A rather fat line
468
469           The HardLW option should be used if you are plotting to a hardcopy
470           device.
471
472       pitch
473           Sets the number of data pixels per inch on the output device.  You
474           can set the "unit" (see below) to change this to any other PGPLOT
475           unit (millimeters, pixels, etc.).   Pitch is device independent, so
476           an image should appear exactly the same size (e.g. "Pitch=>100" is
477           100 dpi) regardless of output device.
478
479       pix Sets the pixel aspect ratio height/width.  The height is adjusted
480           to the correct ratio, while maintaining any otherwise-set pitch or
481           scale in the horizontal direction.  Larger numbers yield tall,
482           skinny pixels; smaller numbers yield short, fat pixels.
483
484       scale
485           Sets the number of output display pixels per data pixel.  You can
486           set the "unit" (see below) to change this to number of PGPLOT units
487           (inches, millimeters, etc.) per data pixel.  "scale" is deprecated,
488           as it is not device-independent; but it does come in handy for
489           quick work on digital displays, where aliasing might otherwise
490           interfere with image interpretation.  For example, "scale=>1"
491           displays images at their native resolution.
492
493       Panel
494           It is possible to define multiple plot ``panels'' with in a single
495           window (see the NXPanel and NYPanel options in the constructor).
496           You can explicitly set in which panel most plotting commands occur,
497           by passing either a scalar or an array ref into the "Panel" option.
498           There is also a panel method, but its use is deprecated because of
499           a wart with the PGPLOT interface.
500
501       plotting & imaging range
502           Explicitly set the plot range in x and y. X-range and Y-range are
503           set separately via the aptly named options "XRange" and "YRange".
504           If omitted PGPLOT selects appropriate defaults (minimum and maximum
505           of the data range in general). These options are ignored if the
506           window is on hold.
507
508             line $x, $y, {xr => [0,5]}; # y-range uses default
509             line $x, $y, {XRange => [0,5], YRange => [-1,3]}; # fully specified range
510             imag $im, {XRange => [30,50], YRange=>[-10,30]};
511             fits_imag $im, {XRange=>[-2,2], YRange=>[0,1]};
512
513           Imaging requires some thought if you don't want to lose a pixel off
514           the edge of the image.  Pixels are value-centered (they are
515           centered on the coordinate whose value they represent), so the
516           appropriate range to plot the entirety of a 100x100 pixel image is
517           "[-0.5,99.5]" on each axis.
518

OBJECT-ORIENTED INTERFACE

520       This section will briefly describe how the
521       PDL::Graphics::PGPLOT::Window package can be used in an object-oriented
522       (OO) approach and what the advantages of this would be. We will start
523       with the latter
524
525       Multiple windows.
526           For the common user it is probably most interesting to use the OO
527           interface when handling several open devices at the same time. If
528           you have one variable for each plot device it is easier to
529           distribute commands to the right device at the right time. This is
530           the angle we will take in the rest of this description.
531
532       Coding and abstraction
533           At a more fundamental level it is desirable to approach a situation
534           where it is possible to have a generic plotting interface which
535           gives access to several plotting libraries, much as PGPLOT gives
536           access to different output devices. Thus in such a hypothetical
537           package one would say:
538
539             my $win1 = Graphics::new('PGPLOT', {Device => '/xs'});
540             my $win2 = Graphics::new('gnuplot', {Background => 'Gray'};
541
542           From a more practical point of of view such abstraction also comes
543           in handy when you write a large program package and you do not want
544           to import routines nilly-willy in which case an OO approach with
545           method calls is a lot cleaner.
546
547           The pgwin exported constructor, arguably, breaks this philosophy;
548           hopefully it will ``wither away'' when other compatible modules are
549           available.
550
551       Anyway, enough philosophizing, let us get down to Earth and give some
552       examples of the use of OO PGPLOT. As an example we will take Odd (which
553       happens to be a common Norwegian name) who is monitoring the birth of
554       rabbits in O'Fib-o-nachy's farm (alternatively he can of course be
555       monitoring processes or do something entirely different). Odd wants the
556       user to be able to monitor both the birth rates and accumulated number
557       of rabbits and the spatial distribution of the births. Since these are
558       logically different he chooses to have two windows open:
559
560         $rate_win = PDL::Graphics::PGPLOT::Window->new(Device => '/xw',
561                     Aspect => 1, WindowWidth => 5, NXPanel => 2);
562
563         $area_win = PDL::Graphics::PGPLOT::Window->new(Device => '/xw',
564                     Aspect => 1, WindowWidth => 5);
565
566       See the documentation for new below for a full overview of the options
567       you can pass to the constructor.
568
569       Next, Odd wants to create plotting areas for subsequent plots and maybe
570       show the expected theoretical trends
571
572         $rate_win->env(0, 10, 0, 1000, {XTitle => 'Days', YTitle => '#Rabbits'});
573         $rate_win->env(0, 10, 0, 100, {Xtitle=>'Days', Ytitle => 'Rabbits/day'});
574
575         $area_win->env(0, 1, 0, 1, {XTitle => 'Km', Ytitle => 'Km'});
576         # And theoretical prediction.
577         $rate_win->line(sequence(10), fibonacci(10), {Panel => [1, 1]});
578
579       That is basically it. The commands should automatically focus the
580       relevant window. Due to the limitations of PGPLOT this might however
581       lead you to plot in the wrong panel... The package tries to be smart
582       and do this correctly, but might get it wrong at times.
583

STATE and RECORDING

585       A new addition to the graphics interface is the ability to record plot
586       commands. This can be useful when you create a nice-looking plot on the
587       screen that you want to re-create on paper for instance. Or if you want
588       to redo it with slightly changed variables for instance. This is still
589       under development and views on the interface are welcome.
590
591       The functionality is somewhat detached from the plotting functions
592       described below so I will discuss them and their use here.
593
594       Recording is off by default. To turn it on when you create a new device
595       you can set the "Recording" option to true, or you can set the
596       $PDL::Graphics::PGPLOT::RECORDING variable to 1. I recommend doing the
597       latter in your ".perldlrc" file at least since you will often have use
598       for recording in the perldl script.
599
600   Use of recording
601       The recording is meant to help you recreate a plot with new data or to
602       a different device. The most typical situation is that you have created
603       a beautiful plot on screen and want to have a Postscript file with it.
604       In the dreary old world you needed to go back and execute all commands
605       manually, but with this wonderful new contraption, the recorder, you
606       can just replay your commands:
607
608         dev '/xs', {Recording => 1}
609         $x = sequence(10)
610         line $x, $x**2, {Linestyle => 'Dashed'}
611         $s = retrieve_state() # Get the current tape out of the recorder.
612         dev '/cps'
613         replay $s
614
615       This should result in a "pgplot.ps" file with a parabola drawn with a
616       dashed line. Note the command "retrieve_state" which retrieves the
617       current state of the recorder and return an object (of type
618       PDL::Graphics::State) that is used to replay commands later.
619
620   Controlling the recording
621       Like any self-respecting recorder you can turn the recorder on and off
622       using the "turn_on_recording" and "turn_off_recording" respectively.
623       Likewise you can clear the state using the "clear_state" command.
624
625         $w=PDL::Graphics::PGPLOT::Window->new(Device => '/xs');
626         $w->turn_on_recording;
627         $x=sequence(10); $y=$x*$x;
628         $w->line($x, $y);
629         $w->turn_off_recording;
630         $w->line($y, $x);
631         $w->turn_on_recording;
632         $w->line($x, $y*$x);
633         $state = $w->retrieve_state();
634
635       We can then replay $state and get a parabola and a cubic plot.
636
637         $w->replay($state);
638
639   Tips and Gotchas!
640       The data are stored in the state object as references to the real data.
641       This leads to one good and one potentially bad consequence:
642
643       The good is that you can create the plot and then subsequently redo the
644       same plot using a different set of data. This is best explained by an
645       example. Let us first create a simple gradient image and get a copy of
646       the recording:
647             $im = sequence(10,10)
648             imag $im
649             $s=retrieve_state
650
651           Now this was a rather dull plot, and in reality we wanted to show
652           an image using "rvals". Instead of re-creating the plot (which of
653           course here would be the simplest option) we just change $im:
654
655             $im -= sequence(10,10)
656             $im += rvals(10,10)
657
658           Now replay the commands
659
660             replay $s
661
662           And hey presto! A totally different plot. Note however the trickery
663           required to avoid losing reference to $im
664
665       This takes us immediately to the major problem with the recording
666       though. Memory leakage! Since the recording keeps references to the
667       data it can keep data from being freed (zero reference count) when you
668       expect it to be. For instance, in this example, we lose totally track
669       of the original $im variable, but since there is a reference to it in
670       the state it will not be freed
671             $im = sequence(1000,1000)
672             imag $im
673             $s = retrieve_state
674             $im = rvals(10,10)
675
676           Thus after the execution of these commands we still have a
677           reference to a 1000x1000 array which takes up a lot of memory...
678
679           The solution is to call "clear" on the state variable:
680
681             $s->clear()
682
683           (This is done automatically if the variable goes out of scope). I
684           forsee this problem to most acute when working on the "perldl"
685           command line, but since this is exactly where the recording is most
686           useful the best advice is just to be careful and call clear on
687           state variables.
688
689           If you are working with scripts and use large images for instance I
690           would instead recommend that you do not turn on recording unless
691           you need it.
692

FUNCTIONS

694       A more detailed listing of the functions and their usage follows. For
695       all functions we specify which options take effect and what other
696       options exist for the given function. The function descriptions below
697       are all given for the non-OO usage for historical reasons, but since
698       the conversion to an OO method is trivial there is no major need for
699       concern. Whenever you see a function example of the form
700
701         Usage: a_simple_function($x, $y, $z [, $opt]);
702
703       and you wish to use the OO version, just let your mind read the above
704       line as:
705
706         Usage: $win->a_simple_function($x, $y, $z [, $opt]);
707
708       where $win is a PDL::Graphics::PGPLOT::Window object. That is all.
709
710   Window control functions.
711   pgwin
712       Exported constructor for PGPLOT object/device/plot window.
713
714        Usage: pgwin($opt);
715        Usage: pgwin($option->$value,...);
716        Usage: pgwin($device);
717
718       Parameters are passed on to new() and can either be specified by hash
719       reference or as a list.
720
721       See the documentation fo PDL::Graphics::PGPLOT::Window::new for
722       details.
723
724       Because pgwin is a convenience function, you can specify the device by
725       passing in a single non-ref parameter.  For even further convenience,
726       you can even omit the '/' in the device specifier, so these two lines
727       deliver the same result:
728
729           $a = pgwin(gif);
730           $a = new PDL::Graphics::PGPLOT::Window({Dev=>'/gif'});
731
732   new
733       Constructor for PGPLOT object/device/plot window.
734
735         Usage: PDL::Graphics::PGPLOT::Window->new($opt);
736         Usage: PDL::Graphics::PGPLOT::Window->new($option=>$value,...);
737
738       Options to new() can either be specified via a reference to a hash
739
740         $win = PDL::Graphics::PGPLOT::Window->new({Dev=>'/xserve',ny=>2});
741
742       or directly, as an array
743
744         # NOTE: no more {} !
745         $win = PDL::Graphics::PGPLOT::Window->new(Dev=>'/xserve',ny=>2);
746
747       The following lists the recognised options:
748
749       AspectRatio
750           The aspect ratio of the image, in the sense vertical/horizontal.
751           See the discussion on size setting.
752
753       Device
754           The type of device to use. The syntax of this is the one used by
755           PGPLOT.
756
757       Hold
758           Hold the plot window so that subsequent plots can plot over
759           existing plots.  This can be adjusted with the "hold()" and
760           "release()" methods.
761
762       NXPanel
763           The number of panels in the X-direction
764
765       NYPanel
766           The number of panels in the Y-direction
767
768       Size
769           Yet another way to identify the plot window size -- this takes a
770           scalar or an array ref containing one, two, or three numbers.  One
771           number gives you a square window.  Two gives you a rectangular
772           window "(X,Y)".  Three lets you specify the unit compactly (e.g.
773           "[<X>,<Y>,1]" for inches, "[<X>,<Y>,2]" for mm) but is deprecated
774           in favor of using the "Unit" option.  See the discussion on size
775           setting.
776
777       Unit
778           The unit to use for size setting.  PGPLOT accepts inch, mm, or
779           pixel.  The default unit is inches for historical reasons, but you
780           can choose millimeters or (God forbid) pixels as well.  String or
781           numeric specifications are OK (0=normalized, 1=inches, 2=mm,
782           3=pixels).  Normalized units make no sense here and are not
783           accepted.  Ideally someone will one day hook this into the CPAN
784           units parser so you can specify window size in rods or attoparsecs.
785
786       WindowName
787           The name to give to the window. No particular use is made of this
788           at present.  It would be great if it was possible to change the
789           title of the window frame.
790
791       WindowWidth
792           The width of the window in inches (or the specified Unit).  See the
793           discussion on size setting.
794
795       WindowXSize and WindowYSize
796           The width and height of the window in inches (or the specified
797           Unit).  See the discussion on size setting.
798
799       An important point to note is that the default values of most options
800       can be specified by passing these to the constructor. All general
801       options (common to several functions) can be adjusted in such a way,
802       but function specific options can not be set in this way (this is a
803       design limitation which is unlikely to be changed).
804
805       Thus the following call will set up a window where the default axis
806       colour will be yellow and where plot lines normally have red colour and
807       dashed linestyle.
808
809         $win = PDL::Graphics::PGPLOT::Window->new(Device => '/xs',
810                 AxisColour => 'Yellow', Colour => 'Red', LineStyle => 'Dashed');
811
812       Size setting: There are a gazillion ways to set window size, in keeping
813       with TIMTOWTDI.  In general you can get away with passing any unique
814       combination of an "<X>" size, a "<Y>"size, and/or an aspect ratio.  In
815       increasing order of precedence, the options are: ("Units",
816       "AspectRatio", "WindowWidth", "Window<X,Y>Size", "Size").
817
818       So if you specify an AspectRatio *and* an X and a Y coordinate, the
819       AspectRatio is ignored.  Likewise, if you specify Units and a three-
820       component Size, the Units option is ignored in favor of the numeric
821       unit in the Size.
822
823       If you don't specify enough information to set the size of the window,
824       you get the default pane size and shape for that device.
825
826   close
827       Close a plot window
828
829         Usage: $win->close()
830
831       Close the current window. This does not necessarily mean that the
832       window is removed from your screen, but it does ensure that the device
833       is closed.
834
835       A message will be printed to STDOUT giving the name of the file created
836       if the plot was made to a hardcopy device and $PDL::verbose is true.
837
838   held
839       Check if a window is on hold
840
841         $is_held = $win->held();
842
843       Function to check whether the window is held or not.
844
845   hold
846       Hold the present window.
847
848        Usage: $win->hold()
849
850       Holds the present window so that subsequent plot commands overplots.
851
852   panel
853       Switch to a different panel
854
855         $win->panel(<num>);
856
857       Move to a different panel on the plotting surface. Note that you will
858       need to erase it manually if that is what you require.
859
860       This routine currently does something you probably don't want, and
861       hence is deprecated for most use:  if you say
862
863         $win->panel(1);
864         $win->imag($image);
865
866       then $image will actually be displayed in panel 2.  That's because the
867       main plotting routines such as line and imag all advance the panel when
868       necessary.  Instead, it's better to use the Panel option within
869       plotting commands, if you want to set the panel explicitly.
870
871   release
872       Release a plot window.
873
874          $win->release()
875
876       Release a plot window so that subsequent plot commands move to the next
877       panel or erase the plot and create a new plot.
878
879   erase
880       Erase plot
881
882         $win->erase($opt);
883
884       Erase a plot area. This accepts the option "Panel" or alternatively a
885       number or array reference which makes it possible to specify the panel
886       to erase when working with several panels.
887
888   Plotting functions
889   env
890       Define a plot window, and put graphics on 'hold'
891
892        $win->env( $xmin, $xmax, $ymin, $ymax, [$justify, $axis] );
893        $win->env( $xmin, $xmax, $ymin, $ymax, [$options] );
894
895       $xmin, $xmax, $ymin, $ymax are the plot boundaries.  $justify is a
896       boolean value (default is 0); if true the axes scales will be the same
897       (see "justify").  $axis describes how the axes should be drawn (see
898       "axis") and defaults to 0.
899
900       If the second form is used, $justify and $axis can be set in the
901       options hash, for example:
902
903        $win->env( 0, 100, 0, 50, {JUSTIFY => 1, AXIS => 'GRID',
904                                   CHARSIZE => 0.7} );
905
906       In addition the following options can also be set for "env":
907
908       PlotPosition
909           The position of the plot on the page relative to the view surface
910           in normalised coordinates as an anonymous array. The array should
911           contain the lower and upper X-limits and then the lower and upper
912           Y-limits. To place two plots above each other with no space between
913           them you could do
914
915             $win->env(0, 1, 0, 1, {PlotPosition => [0.1, 0.5, 0.1, 0.5]});
916             $win->env(5, 9, 0, 8, {PlotPosition => [0.1, 0.5, 0.5, 0.9]});
917
918       Axis, Justify, Border
919           See the description of general options for these options.
920
921       AxisColour
922           Set the colour of the coordinate axes.
923
924       XTitle, YTitle, Title, Font, CharSize
925           Axes titles and the font and size to print them.
926
927   label_axes
928       Label plot axes
929
930         $win->label_axes(<xtitle>, <ytitle>, <plot title>, $options);
931
932       Draw labels for each axis on a plot.
933
934   imag
935       Display an image (uses "pgimag()"/"pggray()" as appropriate)
936
937        $win->imag ( $image,  [$min, $max, $transform], [$opt] )
938
939       NOTES
940
941       $transform for image/cont etc. is used in the same way as the "TR()"
942       array in the underlying PGPLOT FORTRAN routine but is, fortunately,
943       zero-offset. The transform() routine can be used to create this piddle.
944
945       If $image is two-dimensional, you get a grey or pseudocolor image using
946       the scalar values at each X,Y point.  If $image is three-dimensional
947       and the third dimension has order 3, then it is treated as an RGB true-
948       color image via rgbi.
949
950       There are several options related to scaling.  By default, the image is
951       scaled to fit the PGPLOT default viewport on the screen.  Scaling,
952       aspect ratio preservation, and 1:1 pixel mapping are available.  (1:1
953       pixel mapping is useful for avoiding display artifacts, but it's not
954       recommended for final output as it's not device-independent.)
955
956       Here's an additional complication: the "pixel" stuff refers not
957       (necessarily) to normal image pixels, but rather to transformed image
958       pixels.  That is to say, if you feed in a transform matrix via the
959       "TRANSFORM" option, the "PIX", "SCALE", etc. options all refer to the
960       transformed coordinates and not physical image pixels.  That is a Good
961       Thing because it, e.g., lets you specify plate scales of your output
962       plots directly!  See fits_imag for an example application.  If you do
963       not feed in a transform matrix, then the identity matrix is applied so
964       that the scaling options refer to original data pixels.
965
966       To draw a colour bar (or wedge), either use the "DrawWedge" option, or
967       the "draw_wedge()" routine (once the image has been drawn).
968
969       Options recognised:
970
971       ITF
972          the image transfer function applied to the pixel values.  It may be
973          one of 'LINEAR', 'LOG', 'SQRT' (lower case is acceptable). It
974          defaults to 'LINEAR'.
975
976       MIN
977          Sets the minimum value to be used for calculation of the color-table
978          stretch.
979
980       MAX
981          Sets the maximum value for the same.
982
983       RANGE
984          A more compact way to specify MIN and MAX, as a list: you can say
985          "Range=>[0,10]" to scale the color table for brightness values
986          between 0 and 10 in the iamge data.
987
988       CRANGE
989          Image values between MIN and MAX are scaled to an interval in
990          normalized color domain space, on the interval [0,1], before lookup
991          in the window's color table. CRANGE lets you use only a part of the
992          color table by specifying your own range -- e.g. if you say
993          "CRange=>[0.25,0.75]" then only the middle half of the pseudocolor
994          space will be used.  (See the writeup on ctab().)
995
996       TRANSFORM
997          The PGPLOT transform 'matrix' as a 6x1 vector for display
998
999       DrawWedge
1000          set to 1 to draw a colour bar (default is 0)
1001
1002       Wedge
1003          see the draw_wedge() routine
1004
1005       The following standard options influence this command:
1006
1007        AXIS, BORDER, JUSTIFY, SCALE, PIX, PITCH, ALIGN, XRANGE, YRANGE
1008
1009          To see an image with maximum size in the current window, but square
1010          pixels, say:
1011                $win->imag( $a, { PIX=>1 } );
1012          An alternative approach is to try:
1013                $win->imag( $a, { JUSTIFY=>1 } );
1014          To see the same image, scaled 1:1 with device pixels, say:
1015                $win->imag( $a, { SCALE=>1 } );
1016          To see an image made on a device with 1:2 pixel aspect ratio, with
1017          X pixels the same as original image pixels, say
1018                $win->imag( $a, { PIX=>0.5, SCALE=>2 } );
1019          To display an image at 100 dpi on any device, say:
1020                $win->imag( $a, { PITCH=>100 } );
1021          To display an image with 100 micron pixels, say:
1022                $win->imag( $a, { PITCH=>10, UNIT=>'mm' } );
1023
1024   imag1
1025       Display an image with correct aspect ratio
1026
1027        $win->imag1 ( $image, [$min, $max, $transform], [$opt] )
1028
1029       This is syntactic sugar for
1030
1031         $win->imag( { PIX=>1, ALIGN=>'CC' } );
1032
1033   rgbi
1034       Display an RGB color image
1035
1036       The calling sequence is exactly like "imag", except that the input
1037       image must have three dimensions: "N x M x 3".  The last dimension is
1038       the (R,G,B) color value.  This routine requires pgplot 5.3devel or
1039       later.  Calling rgbi explicitly is not necessary, as calling image with
1040       an appropriately dimensioned RGB triplet makes it fall through to rgbi.
1041
1042   fits_imag
1043       Display a FITS image with correct axes
1044
1045         $win->fits_imag( image,  [$min, $max], [$opt] );
1046
1047       NOTES
1048
1049       Titles:
1050          Currently fits_imag also generates titles for you by default and
1051          appends the FITS header scientific units if they're present.  So if
1052          you say
1053
1054            $pdl->hdr->{CTYPE1} = "Flamziness";
1055            $pdl->hdr->{CUNIT1} = "milliBleems";
1056            $win->fits_imag($pdl);
1057
1058          then you get an X title of "Flamziness (milliBleems)".  But you can
1059          (of course) override that by specifying the XTitle and YTitle
1060          switches:
1061
1062            $win->fits_imag($pdl,{Xtitle=>"Arbitrary"});
1063
1064          will give you "Arbitrary" as an X axis title, regardless of what's
1065          in the header.
1066
1067       Scaling and aspect ratio:
1068          If CUNIT1 and CUNIT2 (or, if they're missing, CTYPE1 and CTYPE2)
1069          agree, then the default pixel aspect ratio is 1 (in scientific
1070          units, NOT in original pixels).  If they don't agree (as for a
1071          spectrum) then the default pixel aspect ratio is adjusted
1072          automatically to match the plot viewport and other options you've
1073          specified.
1074
1075          You can override the image scaling using the SCALE, PIX, or PITCH
1076          options just as with the imag() method -- but those parameters refer
1077          to the scientific coordinate system rather than to the pixel
1078          coordinate system (e.g. "PITCH=>100" means "100 scientific units per
1079          inch", and "SCALE=>1" means "1 scientific unit per device pixel").
1080          See the imag() writeup for more info on these options.
1081
1082          The default value of the "ALIGN" option is 'CC' -- centering the
1083          image both vertically and horizontally.
1084
1085       Axis direction:
1086          By default, fits_imag tries to guess which direction your axes are
1087          meant to go (left-to-right or right-to-left) using the CDELT
1088          keywords: if "CDELT" is negative, then rather than reflecting the
1089          image fits_imag will plot the X axis so that the highest values are
1090          on the left.
1091
1092          This is the most convenient behavior for folks who use calibrated
1093          (RA,DEC) images, but it is technically incorrect.  To force the
1094          direction, use the DirAxis option.  Setting "DirAxis=>1"
1095          (abbreviated "di=>1") will force the scientific axes to increase to
1096          the right, reversing the image as necessary.
1097
1098       Color wedge:
1099          By default fits_imag draws a color wedge on the right; you can
1100          explicitly set the "DrawWedge" option to 0 to avoid this.  Use the
1101          "WTitle" option to set the wedge title.
1102
1103       Alternate WCS coordinates:
1104          The default behaviour is to use the primary/default WCS information
1105          in the FITS header (i.e. the "CRVAL1","CRPIX1",... keywords). The
1106          Greisen et al. standard
1107          (<http://fits.cv.nrao.edu/documents/wcs/wcs.html>) allows
1108          alternative/additional mappings to be included in a header; these
1109          are denoted by the letters "A" to "Z". If you know that your image
1110          contains such a mapping then you can use the "WCS" option to select
1111          the appropriate letter. For example, if you had read in a Chandra
1112          image created by the CIAO software package then you can display the
1113          image in the "physical" coordinate system by saying:
1114
1115            $win->fits_imag( $pdl, { wcs => 'p' } );
1116
1117          The identity transform is used if you select a mapping for which
1118          there is no information in the header.  Please note that this suport
1119          is experimental and is not guaranteed to work correctly; please see
1120          the documentation for the _FITS_tr routine for more information.
1121
1122   fits_rgbi
1123       Display an RGB FITS image with correct axes
1124
1125         $win->fits_rgbi( image, [$min,$max], [$opt] );
1126
1127       Works exactly like fits_imag, but the image must be in (X,Y,RGB) form.
1128       Only the first two axes of the FITS header are examined.
1129
1130   fits_cont
1131       Draw contours of an image, labelling the axes using the WCS information
1132       in the FITS header of the image.
1133
1134         $win->fits_cont( image, [$contours, $transform, $misval], [$opt] )
1135
1136       Does the same thing for the cont routine that fits_imag does for the
1137       imag routins.
1138
1139   draw_wedge
1140       Add a wedge (colour bar) to an image.
1141
1142        $win->draw_wedge( [$opt] )
1143
1144       Adds a wedge - shows the mapping between colour and value for a pixel -
1145       to the current image.  This can also be achieved by setting "DrawWedge"
1146       to 1 when calling the "imag" routine.
1147
1148       The colour and font size are the same as used to draw the image axes
1149       (although this will probably fail if you did it yourself).  To control
1150       the size and location of the wedge, use the "Wedge" option, giving it a
1151       hash reference containing any of the following:
1152
1153       Side
1154           Which side of the image to draw the wedge: can be one of 'B', 'L',
1155           'T', or 'R'. Default is 'R'.
1156
1157       Displacement
1158           How far from the egde of the image should the wedge be drawn, in
1159           units of character size. To draw within the image use a negative
1160           value. Default is 1.5.
1161
1162       Width
1163           How wide should the wedge be, in units of character size.  Default
1164           is 2.
1165
1166       Label
1167           A text label to be added to the wedge.  If set, it is probably
1168           worth increasing the "Width" value by about 1 to keep the text
1169           readable.  Default is ''.  This is equivalent to the "WTitle"
1170           option to imag, fits_imag, and similar methods.
1171
1172       ForeGround (synonym Fg)
1173           The pixel value corresponding to the "maximum" colour.  If "undef",
1174           uses the value used by "imag" (recommended choice).  Default is
1175           "undef".
1176
1177       BackGround (synonym Bg)
1178           The pixel value corresponding to the "minimum" colour.  If "undef",
1179           uses the value used by "imag" (recommended choice).  Default is
1180           "undef".
1181
1182        $a = rvals(50,50);
1183        $win = PDL::Graphics::PGPLOT::Window->new();
1184        $win->imag( $a, { Justify => 1, ITF => 'sqrt' } );
1185        $win->draw_wedge( { Wedge => { Width => 4, Label => 'foo' } } );
1186        # although the following might be more sensible
1187        $win->imag( $a, { Justify => 1, ITF => 'sqrt', DrawWedge => 1,
1188            Wedge => { Width => 4, Label => 'foo'} } );
1189
1190   ctab
1191       Load an image colour table.
1192
1193        Usage:
1194
1195          ctab ( $name, [$contrast, $brightness] ) # Builtin col table
1196          ctab ( $ctab, [$contrast, $brightness] ) # $ctab is Nx4 array
1197          ctab ( $levels, $red, $green, $blue, [$contrast, $brightness] )
1198          ctab ( '', $contrast, $brightness ) # use last color table
1199
1200       Note: See PDL::Graphics::LUT for access to a large number of colour
1201       tables.
1202
1203       Notionally, all non-RGB images and vectors have their colors looked up
1204       in the window's color table.  Colors in images and such are scaled to a
1205       normalized pseudocolor domain on the line segment [0,1]; the color
1206       table is a piecewise linear function that maps this one-dimensional
1207       scale to the three-dimensional normalized RGB color space [0,1]^3.
1208
1209       You can specify specific indexed colors by appropriate use of the
1210       (levels,red,green,blue) syntax -- but that is deprecated, since the
1211       actual available number of colors can change depending on the output
1212       device.  (Someone needs to write a specific hardware-dependent lookup
1213       table interface).
1214
1215       See also imag for a description of how to use only part of the color
1216       table for a particular image.
1217
1218   ctab_info
1219       Return information about the currently loaded color table
1220
1221   autolog
1222       Turn on automatic logarithmic scaling in "line" and "points"
1223
1224         Usage:  autolog([0|1]);
1225
1226       Setting the argument to 1 turns on automatic log scaling and setting it
1227       to zero turns it off again. The function can be used in both the object
1228       oriented and standard interface. To learn more, see the documentation
1229       for the axis option.
1230
1231          my $win = PDL::Graphics::PGPLOT::Window->new(dev=>'/xserve');
1232          my $x=sequence(10);
1233          my $y=$x*$x+1;
1234
1235          $win->autolog(1);
1236          $win->line($x,$y, {Axis => 'LogY'});
1237
1238   line
1239       Plot vector as connected points
1240
1241       If the 'MISSING' option is specified, those points in the $y vector
1242       which are equal to the MISSING value are not plotted, but are skipped
1243       over.  This allows one to quickly draw multiple lines with one call to
1244       "line", for example to draw coastlines for maps.
1245
1246        Usage: line ( [$x,] $y, [$opt] )
1247
1248       The following standard options influence this command:
1249
1250        AXIS, BORDER, COLO(U)R, LINESTYLE, LINEWIDTH, MISSING,
1251        JUSTIFY, SCALE, PITCH, PIX, ALIGN
1252
1253        $x = sequence(10)/10.;
1254        $y = sin($x)**2;
1255        # Draw a red dot-dashed line
1256        line $x, $y, {COLOR => 'RED', LINESTYLE=>3};
1257
1258   lines
1259       Plot a list of vectors as discrete sets of connected points
1260
1261       This works much like line, but for discrete sets of connected points.
1262       There are two ways to break lines: you can pass in x/y coordinates just
1263       like in line, but with an additional "pen" piddle that indicates
1264       whether the pen is up or down on the line segment following each point
1265       (so you set it to zero at the end of each line segment you want to
1266       draw);  or you can pass in an array ref containing a list of single
1267       polylines to draw.
1268
1269       Happily, there's extra meaning packed into the "pen" piddle: it
1270       multiplies the COLO(U)R that you set, so if you feed in boolean values
1271       you get what you expect -- but you can also feed in integer or
1272       floating-point values to get multicolored lines.
1273
1274       Furthermore, the sign bit of "pen" can be used to draw hairline
1275       segments: if "pen" is negative, then the segment is drawn as though it
1276       were positive but with LineWidth and HardLW set to 1 (the minimum).
1277
1278       Equally happily, even if you are using the array ref mechanism to break
1279       your polylines you can feed in an array ref of "pen" values to take
1280       advantage of the color functionality or further dice your polylines.
1281
1282       Note that, unlike line, "lines" has no no specify-$y-only calling path.
1283       That's because "lines" is intended more for line art than for plotting,
1284       so you always have to specify both $x and $y.
1285
1286       Infinite or bad values are ignored -- that is to say, if your vector
1287       contains a non-finite point, that point breaks the vector just as if
1288       you set pen=0 for both that point and the point before it.
1289
1290        Usage: $w->( $x, $y, [$pen], [$opt] );
1291               $w->( $xy, [$pen], [$opt] );
1292               $w->( \@xvects, \@yvects, [\@pen], [$opt] );
1293               $w->( \@xyvects, [\@pen], [$opt] );
1294
1295       The following standard options influence this command:
1296        AXIS, BORDER, COLO(U)R, LINESTYLE, LINEWIDTH, MISSING,
1297        JUSTIFY, SCALE, PITCH, PIX, ALIGN
1298
1299       CAVEAT:
1300
1301       Setting "pen" elements to 0 prevents drawing altogether, so you can't
1302       use that to draw in the background color.
1303
1304   points
1305       Plot vector as points
1306
1307        Usage: points ( [$x,] $y, [$symbol(s)], [$opt] )
1308
1309       Options recognised:
1310
1311          SYMBOL - Either a piddle with the same dimensions as $x, containing
1312                   the symbol associated to each point or a number specifying
1313                   the symbol to use for every point, or a name specifying the
1314                   symbol to use according to the following (recognised name in
1315                    capital letters):
1316                    0 - SQUARE   1 - DOT     2 - PLUS     3 - ASTERISK
1317                    4 - CIRCLE   5 - CROSS   7 - TRIANGLE 8 - EARTH
1318                    9 - SUN     11 - DIAMOND 12- STAR
1319        PLOTLINE - If this is >0 a line will be drawn through the points.
1320
1321       The following standard options influence this command:
1322
1323        AXIS, BORDER, CHARSIZE, COLOUR, LINESTYLE, LINEWIDTH,
1324        JUSTIFY, SCALE, PIX, PITCH, ALIGN
1325
1326       "SymbolSize" allows to adjust the symbol size, it defaults to CharSize.
1327
1328       The "ColorValues" option allows one to plot XYZ data with the Z axis
1329       mapped to a color value.  For example:
1330
1331        use PDL::Graphics::LUT;
1332        ctab(lut_data('idl5')); # set up color palette to 'idl5'
1333        points ($x, $y, {ColorValues => $z});
1334
1335        $y = sequence(10)**2+random(10);
1336        # Plot blue stars with a solid line through:
1337        points $y, {PLOTLINE => 1, COLOUR => BLUE, symbol => STAR}; # case insensitive
1338
1339   errb
1340       Plot error bars (using "pgerrb()")
1341
1342       Usage:
1343
1344        errb ( $y, $yerrors, [$opt] )
1345        errb ( $x, $y, $yerrors, [$opt] )
1346        errb ( $x, $y, $xerrors, $yerrors, [$opt] )
1347        errb ( $x, $y, $xloerr, $xhierr, $yloerr, $yhierr, [$opt])
1348
1349       Any of the error bar parameters may be "undef" to omit those error
1350       bars.
1351
1352       Options recognised:
1353
1354          TERM - Length of terminals in multiples of the default length
1355        SYMBOL - Plot the datapoints using the symbol value given, either
1356                 as name or number - see documentation for 'points'
1357
1358       The following standard options influence this command:
1359
1360        AXIS, BORDER, CHARSIZE, COLOUR, LINESTYLE, LINEWIDTH,
1361        JUSTIFY, SCALE, PIX, PITCH, ALIGN
1362
1363        $y = sequence(10)**2+random(10);
1364        $sigma=0.5*sqrt($y);
1365        errb $y, $sigma, {COLOUR => RED, SYMBOL => 18};
1366
1367        # plot X bars only
1368        errb( $x, $y, $xerrors, undef );
1369
1370        # plot negative going bars only
1371        errb( $x, $y, $xloerr, undef, $yloerr, undef );
1372
1373   cont
1374       Display image as contour map
1375
1376        Usage: cont ( $image,  [$contours, $transform, $misval], [$opt] )
1377
1378       Notes: $transform for image/cont etc. is used in the same way as the
1379       "TR()" array in the underlying PGPLOT FORTRAN routine but is,
1380       fortunately, zero-offset. The transform() routine can be used to create
1381       this piddle.
1382
1383       Options recognised:
1384
1385           CONTOURS - A piddle with the contour levels
1386             FOLLOW - Follow the contour lines around (uses pgcont rather than
1387                      pgcons) If this is set >0 the chosen linestyle will be
1388                      ignored and solid line used for the positive contours
1389                      and dashed line for the negative contours.
1390             LABELS - An array of strings with labels for each contour
1391        LABELCOLOUR - The colour of labels if different from the draw colour
1392                      This will not interfere with the setting of draw colour
1393                      using the colour keyword.
1394            MISSING - The value to ignore for contouring
1395          NCONTOURS - The number of contours wanted for automatical creation,
1396                      overridden by CONTOURS
1397          TRANSFORM - The pixel-to-world coordinate transform vector
1398
1399       The following standard options influence this command:
1400
1401        AXIS, BORDER, COLOUR, LINESTYLE, LINEWIDTH,
1402        JUSTIFY, SCALE, PIX, PITCH, ALIGN
1403
1404        $x=sequence(10,10);
1405        $ncont = 4;
1406        $labels= ['COLD', 'COLDER', 'FREEZING', 'NORWAY']
1407        # This will give four blue contour lines labelled in red.
1408        cont $x, {NCONT => $ncont, LABELS => $labels, LABELCOLOR => RED,
1409                  COLOR => BLUE}
1410
1411   bin
1412       Plot vector as histogram (e.g. "bin(hist($data))")
1413
1414        Usage: bin ( [$x,] $data )
1415
1416       Options recognised:
1417
1418        CENTRE - if true, the x values denote the centre of the bin
1419                 otherwise they give the lower-edge (in x) of the bin
1420        CENTER - as CENTRE
1421
1422       The following standard options influence this command:
1423
1424        AXIS, BORDER, COLOUR, JUSTIFY, LINESTYLE, LINEWIDTH
1425
1426   hi2d
1427       Plot image as 2d histogram (not very good IMHO...)
1428
1429        Usage: hi2d ( $image, [$x, $ioff, $bias], [$opt] )
1430
1431       Options recognised:
1432
1433        IOFFSET - The offset for each array slice. >0 slants to the right
1434                                                   <0 to the left.
1435           BIAS - The bias to shift each array slice up by.
1436
1437       The following standard options influence this command:
1438
1439        AXIS, BORDER, JUSTIFY, SCALE, PIX, PITCH, ALIGN
1440
1441       Note that meddling with the "ioffset" and "bias" often will require you
1442       to change the default plot range somewhat. It is also worth noting that
1443       if you have TriD working you will probably be better off using mesh3d
1444       or a similar command - see the PDL::Graphics::TriD module.
1445
1446        $r=sequence(100)/50-1.0;
1447        $y=exp(-$r**2)*transpose(exp(-$r**2))
1448        hi2d $y, {IOFF => 1.5, BIAS => 0.07};
1449
1450   arrow
1451       Plot an arrow
1452
1453        Usage: arrow($x1, $y1, $x2, $y2, [, $opt]);
1454
1455       Plot an arrow from "$x1, $y1" to "$x2, $y2". The arrow shape can be set
1456       using the option "Arrow". See the documentation for general options for
1457       details about this option (and the example below):
1458
1459       Example:
1460
1461         arrow(0, 1, 1, 2, {Arrow => {FS => 1, Angle => 1, Vent => 0.3, Size => 5}});
1462
1463       which draws a broad, large arrow from (0, 1) to (1, 2).
1464
1465   rect
1466       Draw a non-rotated rectangle
1467
1468       Usage: rect ( $x1, $x2, $y1, $y2 )
1469
1470       Options recognised:
1471
1472       The following standard options influence this command:
1473
1474        AXIS, BORDER, COLOUR, FILLTYPE, HATCHING, LINESTYLE,  LINEWIDTH
1475        JUSTIFY, SCALE, PIX, PITCH, ALIGN
1476
1477   poly
1478       Draw a polygon
1479
1480        Usage: poly ( $x, $y )
1481
1482       Options recognised:
1483
1484       The following standard options influence this command:
1485
1486        AXIS, BORDER, COLOUR, FILLTYPE, HATCHING, LINESTYLE,  LINEWIDTH
1487        JUSTIFY, SCALE, PIX, PITCH, ALIGN
1488
1489        # Fill with hatching in two different colours
1490        $x=sequence(10)/10;
1491        # First fill with cyan hatching
1492        poly $x, $x**2, {COLOR=>5, FILL=>3};
1493        hold;
1494        # Then do it over again with the hatching offset in phase:
1495        poly $x, $x**2, {COLOR=>6, FILL=>3, HATCH=>{PHASE=>0.5}};
1496        release;
1497
1498   circle
1499       Plot a circle on the display using the fill setting.
1500
1501        Usage: circle($x, $y, $radius [, $opt]);
1502
1503       All arguments can alternatively be given in the options hash using the
1504       following options:
1505
1506       XCenter and YCenter
1507           The position of the center of the circle
1508
1509       Radius
1510           The radius of the circle.
1511
1512   ellipse
1513       Plot an ellipse, optionally using fill style.
1514
1515        Usage: ellipse($x, $y, $a, $b, $theta [, $opt]);
1516
1517       All arguments can alternatively be given in the options hash using the
1518       following options:
1519
1520       MajorAxis
1521           The major axis of the ellipse - this must be defined or $a must be
1522           given.
1523
1524       MinorAxis
1525           The minor axis, like A this is required.
1526
1527       Theta (synonym Angle)
1528           The orientation of the ellipse - defaults to 0.0. This is given in
1529           radians.
1530
1531       XCenter and YCenter
1532           The coordinates of the center of the ellipse. These must be
1533           specified or $x and $y must be given.
1534
1535       NPoints
1536           The number of points used to draw the ellipse. This defaults to 100
1537           and might need changing in the case of very large ellipses.
1538
1539       The routine also recognises the same standard options as accepted by
1540       poly.
1541
1542   rectangle
1543       Draw a rectangle.
1544
1545        Usage: rectangle($xcenter, $ycenter, $xside, $yside, [, $angle, $opt]);
1546
1547       This routine draws a rectangle with the chosen fill style. Internally
1548       it calls poly which is somewhat slower than "pgrect" but which allows
1549       for rotated rectangles as well. The routine recognises the same options
1550       as "poly" and in addition the following:
1551
1552       XCenter and YCenter
1553           The position of the center of the rectangle. XCentre and YCentre
1554           are valid synonyms.
1555
1556       XSide and YSide
1557           The length of the X and Y sides. If only one is specified the shape
1558           is taken to be square with that as the side-length, alternatively
1559           the user can set Side
1560
1561       Side
1562           The length of the sides of the rectangle (in this case a square) -
1563           syntactic sugar for setting XSide and YSide identical. This is
1564           overridden by XSide or YSide if any of those are set.
1565
1566       Angle (synonym Theta)
1567           The angle at which the rectangle is to be drawn. This defaults to
1568           0.0 and is given in radians.
1569
1570   vect
1571       Display 2 images as a vector field
1572
1573        Usage: vect ( $w, $a, $b, [$scale, $pos, $transform, $misval], { opt } );
1574               $w->vect($a,$b,[$scale,$pos,$transform,$misval], { opt });
1575
1576       Notes: $transform for image/cont etc. is used in the same way as the
1577       "TR()" array in the underlying PGPLOT FORTRAN routine but is,
1578       fortunately, zero-offset. The transform() routine can be used to create
1579       this piddle.
1580
1581       This routine will plot a vector field. $a is the horizontal component
1582       and $b the vertical component.  The scale factor converts between
1583       vector length units and scientific positional units.  You can set the
1584       scale, position, etc. either by passing in parameters in the normal
1585       parameter list or by passing in options.
1586
1587       Options recognised:
1588
1589            SCALE - Set the scale factor for vector lengths.
1590              POS - Set the position of vectors.
1591                    <0 - vector head at coordinate
1592                    >0 - vector base at coordinate
1593                    =0 - vector centered on the coordinate
1594        TRANSFORM - The pixel-to-world coordinate transform vector
1595          MISSING - Elements with this value are ignored.
1596
1597       The following standard options influence this command:
1598
1599        ARROW, ARROWSIZE, AXIS, BORDER, CHARSIZE, COLOUR,
1600        LINESTYLE, LINEWIDTH,
1601
1602        $a=rvals(11,11,{Centre=>[5,5]});
1603        $b=rvals(11,11,{Centre=>[0,0]});
1604        vect $a, $b, {COLOR=>YELLOW, ARROWSIZE=>0.5, LINESTYLE=>dashed};
1605
1606   fits_vect
1607       Display a pair of 2-D piddles as vectors, with FITS header
1608       interpretation
1609
1610        Usage: fits_vect ($a, $b, [$scale, $pos, $transform, $misval] )
1611
1612       "fits_vect" is to vect as fits_imag is to imag.
1613
1614   transform
1615       Create transform array for contour and image plotting
1616
1617        $win->transform([$xdim,$ydim], $options);
1618
1619       (For information on coordinate transforms, try PDL::Transform.)  This
1620       function creates a transform array in the format required by the image
1621       and contouring routines. You must call it with the dimensions of your
1622       image as arguments or pass these as an anonymous hash - see the example
1623       below.
1624
1625       Angle
1626           The rotation angle of the transform, in radians.  Positive numbers
1627           rotate the image clockwise on the screen.
1628
1629       ImageDimensions
1630           The dimensions of the image the transform is required for. The
1631           dimensions should be passed as a reference to an array.
1632
1633       Pixinc
1634           The increment in output coordinate per pixel.
1635
1636       ImageCenter (or ImageCentre)
1637           The centre of the image as an anonymous array or as a scalar, in
1638           scientific coordinates. In the latter case the x and y value for
1639           the center will be set equal to this scalar. This is particularly
1640           useful in the common case when the center is (0, 0).  (ImageCenter
1641           overrides RefPos if both are specified).
1642
1643       RefPos (or ReferencePosition)
1644           If you wish to set a pixel other than the image centre to a given
1645           value, use this option. It should be supplied with a reference to
1646           an array containing 2 2-element array references, e.g.
1647
1648            RefPos => [ [ $xpix, $ypix ], [ $xplot, $yplot ] ]
1649
1650           This will label pixel "($xpix,$ypix)" as being at position
1651           "($xplot,$yplot)".  For example
1652
1653            RefPos      => [ [100,74], [ 0, 0 ] ]
1654
1655           sets the scientific coordinate origin to be at the center of the
1656           (100,74) pixel coordinate.  The pixel coordinates are pixel-
1657           centered, and start counting from 0 (as all good pixel coordinates
1658           should).
1659
1660       Example:
1661
1662          $im = rvals(100, 100);
1663          $w = PDL::Graphics::PGPLOT::Window->new(Device => '/xs');
1664          $t = $w->transform(dims($im), {ImageCenter => 0,  Pixinc => 5});
1665          $w->imag($im, {Transform => $t});
1666
1667   tline
1668       Threaded line plotting
1669
1670        $win->tline($x, $y, $options);
1671
1672       This is a threaded interface to "line". This is convenient if you have
1673       a 2D array and want to plot out every line in one go. The routine will
1674       apply any options you apply in a "reasonable" way. In the sense that it
1675       will loop over the options wrapping over if there are less options than
1676       lines.
1677
1678       Example:
1679
1680         $h={Colour => ['Red', '1', 4], Linestyle => ['Solid' ,'Dashed']};
1681         $tx=zeroes(100,5)->xlinvals(-5,5);
1682         $ty = $tx + $tx->yvals;
1683         $win->tline($tx, $ty, $h);
1684
1685   tpoints
1686       A threaded interface to points
1687
1688        Usage: tpoints($x, $y, $options);
1689
1690       This is a threaded interface to "points". This is convenient if you
1691       have a 2D array and want to plot out every line in one go. The routine
1692       will apply any options you apply in a "reasonable" way. In the sense
1693       that it will loop over the options wrapping over if there are less
1694       options than lines.
1695
1696       Example:
1697
1698         $h={Colour => ['Red', '1', 4], Linestyle => ['Solid' ,'Dashed']};
1699         $tx=zeroes(100,5)->xlinvals(-5,5);
1700         $ty = $tx + $tx->yvals;
1701         tpoints($tx, $ty, $h);
1702
1703   tcircle
1704       A threaded interface to circle
1705
1706        Usage: tcircle($x, $y, $r, $options);
1707
1708       This is a threaded interface to "circle". This is convenient if you
1709       have a list of circle centers and radii and want to draw every circle
1710       in one go.  The routine will apply any options you apply in a
1711       "reasonable" way, in the sense that it will loop over the options
1712       wrapping over if there are less options than circles.
1713
1714       Example:
1715
1716        $x=sequence(5);
1717        $y=random(5);
1718        $r=sequence(5)/10 + 0.1;
1719        $h={justify => 1,Color => ['red','green','blue'], filltype => ['solid','outline','hatched','cross_hatched']};
1720        tcircle($x, $y, $r, $h);
1721
1722       Note that $x and $y must be the same size (>1D is OK, though
1723       meaningless as far as "tcircle" is concerned). $r can be the same size
1724       as $x OR a 1-element piddle OR a single perl scalar.
1725
1726   Text routines
1727   text
1728       Write text in a plot window at a specified position.
1729
1730        Usage: text ($text, $x, $y [, $opt])
1731
1732       Options recognised:
1733
1734       "ANGLE"
1735           The angle in degrees between the baseline of the text and the
1736           horisontal (increasing counter-clockwise). This defaults to 0.
1737
1738       "JUSTIFICATION"
1739           The justification of the text relative to the position specified.
1740           It defaults to 0.0 which gives left-justified text. A value of 0.5
1741           gives centered text and a value of 1.0 gives right-justified text.
1742
1743       "XPos", "YPos", "Text"
1744           These gives alternative ways to specify the text and position.
1745
1746       "BackgroundColour"
1747           This sets the background colour for the text in case an opaque
1748           background is desired. You can also use the synonyms "Bg" and
1749           "BackgroundColor".
1750
1751       The following standard options influence this command:
1752
1753          COLOUR, CHARSIZE
1754
1755         line sequence(10), sequence(10)**2;
1756         text 'A parabola', 3, 9, {Justification => 1, Angle=>atan2(6,1)};
1757
1758   legend
1759       Add a legend to a plot
1760
1761        Usage: legend($text, $x, $y, [, $width], $opt]);
1762
1763       This function adds a legend to an existing plot. The action is
1764       primarily controlled by information in the options hash, and the basic
1765       idea is that $x and $y determines the upper left hand corner of the box
1766       in which the legend goes. If the width is specified either as an
1767       argument or as an option in the option hash this is used to determine
1768       the optimal character size to fit the text into part of this width
1769       (defaults to 0.5 - see the description of "TextFraction" below). The
1770       rest of the width is filled out with either lines or symbols according
1771       to the content of the "LineStyle", "Symbol", "Colour" and "LineWidth"
1772       options.
1773
1774       The local options recognised are as follows:
1775
1776       "Text"
1777           An anonymous array of annotations, can also be specified directly.
1778
1779       "XPos" and "YPos"
1780           The X and Y position of the upper left-hand corner of the text.
1781
1782       "Width" and "Height"
1783           The width and/or height of each line (including symbol/line). This
1784           is used to determine the character size. If any of these are set to
1785           'Automatic' the current character size will be used.
1786
1787       "TextFraction"
1788           The text and the symbol/line is set inside a box. "TextFraction"
1789           determines how much of this box should be devoted to text. This
1790           defaults to 0.5. You can also use "Fraction" as a synonym to this.
1791
1792       "TextShift"
1793           This option allows for fine control of the spacing between the text
1794           and the start of the line/symbol. It is given in fractions of the
1795           total width of the legend box. The default value is 0.1.
1796
1797       "VertSpace" or "VSpace"
1798           By default the text lines are separated by one character height (in
1799           the sense that if the separation were 0 then they would lie on top
1800           of each other). The "VertSpace" option allows you to increase (or
1801           decrease) this gap in units of the character height; a value of 0.5
1802           would add half a character height to the gap between lines, and
1803           -0.5 would remove the same distance.  The default value is 0.
1804
1805       "BackgroundColour"
1806           This sets the background colour for the text in case an opaque
1807           background is desired. You can also use the synonyms "Bg" and
1808           "BackgroundColor".
1809
1810         line $x, $y, {Color => 'Red', LineStyle => 'Solid'};
1811         line $x2, $y2, {Color => 'Blue', 'LineStyle' => 'Dashed', LineWidth => 10};
1812
1813         legend ['A red line', 'A blue line'], 5, 5,
1814             {LineStyle => ['Solid', 'Dashed'], Colour => ['Red', 'Blue']
1815              LineWidth => [undef, 10]}; # undef gives default.
1816
1817   Cursor routines
1818   cursor
1819       Interactively read cursor positions.
1820
1821        Usage: ($x, $y, $ch, $xref, $yref) = cursor($opt)
1822
1823       This routine has no standard input parameters, but the type of cursor
1824       can be set by setting the option "Type" as a key in the anonymous hash
1825       $opt. The first three return values from the function are always
1826       defined and gives the position selected by the user and the character
1827       pressed.
1828
1829       Depending on the cursor type selected the last two arguments might also
1830       be defined and these give a reference position. For instance if the
1831       cursor is selected to be "Rectangle" then the reference position gives
1832       one of the corners of the rectangle and $x and $y the diagonally
1833       opposite one.
1834
1835       Options recognised:
1836
1837       XRef, YRef
1838           The reference position to be used
1839
1840       Type
1841           The type of cursor. This can be selected using a number between 0
1842           and 7 as in PGPLOT, or alternatively you can specify these as,
1843           "Default" (0), "RadialLine" (1), "Rectangle" (2),
1844           "TwoHorizontalLines" (3), "TwoVerticalLines" (4), "HorizontalLine"
1845           (5), "VerticalLine" (6) and "CrossHair" (7) respectively. The
1846           default cursor is just the normal mouse cursor.
1847
1848           For the "RadialLine" you must specify the reference point, whereas
1849           for the "Two(Vertical|Horizontal)Lines" cursor the X or Y reference
1850           point, respectively, must be specified.
1851
1852       To select a region on a plot, use the rectangle cursor:
1853
1854         ($x, $y, $ch, $xref, $yref) = cursor({Type => 'Rectangle'});
1855         poly pdl($x, $xref, $xref, $x, $x), pdl($y, $y, $yref, $yref, $y);
1856
1857       To select a region of the X-axis:
1858
1859         ($x1, $y1, $ch) = cursor({Type => 'VerticalLine'});
1860         ($x2, $y2, $ch) = cursor({Type => 'TwoVerticalLines', XRef => $x1});
1861
1862   Internal routines
1863   signal_catcher, catch_signals, release_signals
1864       To prevent pgplot from doing a fandango on core, we have to block
1865       interrupts during PGPLOT calls.  Specifically, INT needs to get caught.
1866       These internal routines provide a mechanism for that.
1867
1868       You simply bracket any PGPLOT calls with &catch_signals above and
1869       &release_signals below, and the signal_catcher will queue up any
1870       signals (like INT -- the control-C interrupt) until the
1871       &release_signals call.
1872
1873       Any exit path from your hot code must include &release_signals, or
1874       interrupts could be deferred indefinitely (which would be a bug).  This
1875       includes calls to &barf -- even barfs from someone you called!  So
1876       avoid calling out of the local module if possible, and use
1877       release_and_barf() instead of barf() from within this module.
1878
1879       Perl 5.6.1 interrupt handling has a bug that this code tickles --
1880       sometimes the re-emitted signals vanish into hyperspace.  Perl 5.8
1881       seems NOT to have that problem.
1882
1883   _open_new_window
1884       Open a new window. This sets the window ID, which is the one used when
1885       accessing a window later using "pgslct". It also sets the window name
1886       to something easily remembered if it has not been set before.
1887
1888   _setup_window
1889       This routine sets up a new window with its shape and size. This is also
1890       where the size options are actually parsed. These are then forgotten
1891       (well, they are stored in $self->{Options}) and the corresponding
1892       aspect ratio and window width is stored.  See the discussion under
1893       new() for the logic.
1894
1895       Finally the subpanels are set up using "pgsubp" and colours and
1896       linewidth are adjusted according to whether we have a hardcopy device
1897       or not.
1898
1899   _status
1900       This routine checks PGPLOT's status for the window. It returns OPEN if
1901       the window is open and CLOSED if it is closed.  (Windows can be closed
1902       but still exist).
1903
1904   _reopen
1905       This functions reopens a window. Since this is an internal function it
1906       does not have a lot of error-checking. Make sure the device is closed
1907       before calling this routine.
1908
1909       There is an unfortunate problem which pops up viz. that the window name
1910       cannot be changed at this point since we are offering that to the rest
1911       of the world. That might be sensible, but it means that the window name
1912       will not reflect the id of the window - use "id()" for that (this is
1913       also why we do not call "open_new_window" )
1914
1915   _advance_panel
1916       This routine advances one plot panel, updating the CurrentPanel as
1917       well.  If the advance will proceed past the page the page will be
1918       erased. Also note that when you advance one panel the hold value will
1919       be changed.
1920
1921   _check_move_or_erase
1922       This routine is a utility routine which checks if we need to move
1923       panel, and if so will do this. It also checks if it is necessary to
1924       advance panels, and whether they need to be erased.
1925
1926   _thread_options
1927       This function is a cludgy utility function that expands an options hash
1928       to an array of hashes looping over options. This is mainly of use for
1929       "threaded" interfaces to standard plotting routines.
1930
1931   options
1932       Access the options used when originally opening the window. At the
1933       moment this is not updated when the window is changed later.
1934
1935   id
1936       Access the window ID that PGPLOT uses for the present window.
1937
1938   device
1939       This function returns the device type of the present window.
1940
1941   name
1942       Accessor to set and examine the name of a window.
1943
1944   focus
1945       Set focus for subsequent PGPLOT commands to this window.
1946
1947   info
1948       Get general information about the PGPLOT environment.
1949
1950        @ans = $self->info( @item );
1951
1952       The valid values of @item are as below, where case is not important:
1953
1954         VERSION     - What PGPLOT version is in use.
1955         STATE       - The status of the output device, this is returns 'OPEN'.
1956                       if the device is open and 'CLOSED' otherwise.
1957         USER        - The username of the owner of the spawning program.
1958         NOW         - The current date and time in the format
1959                       'dd-MMM-yyyy hh:mm'. Most people are likely to use Perl
1960                       functions instead.
1961         DEVICE    * - The current PGPLOT device or file, see also device().
1962         FILE      * - The filename for the current device.
1963         TYPE      * - And the device type for the current device.
1964         DEV/TYPE  * - This combines DEVICE and TYPE in a form that can be used
1965                       as input to new.
1966         HARDCOPY  * - This is flag which is set to 'YES' if the current device is
1967                       a hardcopy device and 'NO' otherwise.
1968         TERMINAL  * - This flag is set to 'YES' if the current device is the
1969                       user's terminal and 'NO' otherwise.
1970         CURSOR    * - A flag ('YES' or 'NO') to inform whether the current device
1971                       has a cursor.
1972
1973       Those items marced with a "*" only return a valid answer if the window
1974       is open.  A question mark ("?") is returned if the item is not
1975       recognised or the information is not available.
1976
1977   _extract_hash
1978       This routine takes and array and returns the first hash reference found
1979       as well as those elements that are not hashes. Note the latter point
1980       because all other references to hashes in the array will be lost.
1981
1982   _parse_unit
1983       Convert a unit string or number into a PGPLOT-certified length unit
1984       specification, or return undef if it won't go.
1985
1986   _parse_options
1987       This is a convenience routine for parsing a set of options. It returns
1988       both the full set of options and those that the user has set.
1989
1990   _save_status
1991       Saves the PGPLOT state so that changes to settings can be made and then
1992       the present state restored by "_restore_status".
1993
1994   _restore_status
1995       Restore the PGPLOT state. See "_save_status".
1996
1997   _checkarg
1998       This routine checks and optionally alters the arguments given to it.
1999
2000   _set_colour
2001       This is an internal routine that encapsulates all the nastiness of
2002       setting colours depending on the different PGPLOT colour models
2003       (although HLS is not supported).
2004
2005       The routine works in the following way:
2006
2007       ·       At initialisation of the plot device the work colour index is
2008               set to 16. The work index is the index the routine will modify
2009               unless the user has specified something else.
2010
2011       ·       The routine should be used after standard interpretation and
2012               synonym matching has been used. So if the colour is given as
2013               input is an integer that colour index is used.
2014
2015       ·       If the colour is a reference the routine checks whether it is
2016               an "ARRAY" or a "PDL" reference. If it is not an error message
2017               is given.  If it is a "PDL" reference it will be converted to
2018               an array ref.
2019
2020       ·       If the array has four elements the first element is interpreted
2021               as the colour index to modify and this overrules the setting
2022               for the work index used internally. Otherwise the work index is
2023               used and incremented until the maximum number of colours for
2024               the output device is reached (as indicated by "pgqcol"). Should
2025               you wish to change that you need to read the PGPLOT
2026               documentation - it is somewhat device dependent.
2027
2028       ·       When the array has been recognised the R,G and B colours of the
2029               user-set index or work index is set using the "pgscr" command
2030               and we are finished.
2031
2032       ·       If the input colour instead is a string we try to set the
2033               colour using the PGPLOT routine "pgscrn" with no other error-
2034               checking. This should be ok,  as that routine returns a rather
2035               sensible error-message.
2036
2037   _standard_options_parser
2038       This internal routine is the default routine for parsing options. This
2039       routine deals with a subset of options that most routines will accept.
2040
2041   _image_xyrange
2042       Given a PGPLOT tr matrix and an image size, calculate the data world
2043       coordinates over which the image ranges.  This is used in imag and
2044       cont.  It keeps track of the required half-pixel offset to display
2045       images properly -- eg feeding in no tr matrix at all, nx=20, and ny=20
2046       will will return (-0.5,19.5,-0.5,19.5).  It also checks the options
2047       hash for XRange/YRange specifications and, if they are present, it
2048       overrides the appropriate output with the exact ranges in those fields.
2049
2050   _FITS_tr
2051       Given a FITS image, return the PGPLOT transformation matrix to convert
2052       pixel coordinates to scientific coordinates.   Used by fits_imag,
2053       fits_rgbi, and fits_cont, but may come in handy for other methods.
2054
2055         my $tr = _FITS_tr( $win, $img );
2056         my $tr = _FITS_tr( $win, $img, $opts );
2057
2058       The return value ($tr in the examples above) is the same as returned by
2059       the transform() routine, with values set up to convert the pixel to
2060       scientific coordinate values for the two-dimensional image $img. The
2061       $opts argument is optional and should be a HASH reference; currently it
2062       only understands one key (any others are ignored):
2063
2064         WCS => undef (default), "", or "A" to "Z"
2065
2066       Both the key name and value are case insensitive. If left as "undef" or
2067       "" then the primary coordinate mapping from the header is used,
2068       otherwise use the additional WCS mapping given by the appropriate
2069       letter.  We make no checks that the given mapping is available; the
2070       routine falls back to the unit mapping if the specified system is not
2071       available.
2072
2073       The WCS option has only been tested on images from the Chandra X-ray
2074       satellite (<http://chandra.harvard.edu/>) created by the CIAO software
2075       package (<http://cxc.harvard.edu/ciao/>), for which you should set "WCS
2076       => "P"" to use the "PHYSICAL" coordinate system.
2077
2078       See <http://fits.cv.nrao.edu/documents/wcs/wcs.html> for further
2079       information on the Representation of World Coordinate Systems in FITS.
2080

INTERNAL

2082       The coding tries to follow reasonable standards, so that all functions
2083       starting with an underscore should be considered as internal and should
2084       not be called from outside the package. In addition most routines have
2085       a set of options. These are encapsulated and are not accessible outside
2086       the routine. This is to avoid collisions between different variables.
2087

AUTHOR

2089       Karl Glazebrook [kgb@aaoepp.aao.gov.au] modified by Jarle Brinchmann
2090       (jarle@astro.ox.ac.uk) who is also responsible for the OO interface,
2091       docs mangled by Tuomas J. Lukka (lukka@fas.harvard.edu) and Christian
2092       Soeller (c.soeller@auckland.ac.nz). Further contributions and bugfixes
2093       from Kaj Wiik, Doug Burke, Craig DeForest, and many others.
2094
2095       All rights reserved. There is no warranty. You are allowed to
2096       redistribute this software / documentation under certain conditions.
2097       For details, see the file COPYING in the PDL distribution. If this file
2098       is separated from the PDL distribution, the copyright notice should be
2099       included in the file.
2100
2101
2102
2103perl v5.12.3                      2009-10-24                         Window(3)
Impressum