=head1 OVERVIEW
This is a Gnuplot-based plotter for PDL. This repository stores the history for the PDL::Graphics::Gnuplot module on CPAN. Install the module via CPAN. CPAN page at Lhttp://metacpan.org/pod/PDL::Graphics::Gnuplot.
=cut
=encoding UTF-8
=head1 NAME
PDL::Graphics::Gnuplot - Gnuplot-based plotting for PDL
=head1 SYNOPSIS
pdl> use PDL::Graphics::Gnuplot;
pdl> $x = sequence(101) - 50; pdl> gplot($x2); pdl> gplot($x2,{xr=>[0,50]});
pdl> gplot( {title => 'Parabola with error bars'}, with => 'xyerrorbars', legend => 'Parabola', $x*2 10, abs($x)/10, abs($x)*5 );
pdl> $xy = zeroes(21,21)->ndcoords - pdl(10,10); pdl> $z = inner($xy, $xy); pdl> gplot({title => 'Heat map', trid => 1, view => [0,0] }, with => 'image', xvals($z),yvals($z),zeroes($z),$z*2 );
pdl> $w = gpwin(); # constructor pdl> $pi = 3.14159; pdl> $theta = zeroes(200)->xlinvals(0, 6*$pi); pdl> $z = zeroes(200)->xlinvals(0, 5); pdl> $w->plot3d(cos($theta), sin($theta), $z); pdl> $w->terminfo(); # get information
=head1 DESCRIPTION
This module allows PDL data to be plotted using Gnuplot as a backend for 2D and 3D plotting and image display. Gnuplot (not affiliated with the GNU project) is a venerable, open-source program that produces both interactive and publication-quality plots on many different output devices. It is available through most Linux repositories, on MacOS, and from its website Lhttp://www.gnuplot.info.
It is not necessary to understand the gnuplot syntax to generate basic, or even complex, plots - though the full syntax is available for advanced users who want the full flexibility of the Gnuplot backend.
For a very quick demonstration of the power of this module, see L<this YouTube demo video|https://www.youtube.com/watch?v=hUXDQL3rZ_0>, and others on visualisation of L<tesseract assembly|https://www.youtube.com/watch?v=ykQmNrSKqGQ> and L<rotation|https://www.youtube.com/watch?v=6tpsPYBrHy0>.
Gnuplot recognizes both hard-copy and interactive plotting devices, and on interactive devices (like X11) it is possible to pan, scale, and rotate both 2-D and 3-D plots interactively. You can also enter graphical data through mouse clicks on the device window. On some hardcopy devices (e.g. "PDF") that support multipage output, it is necessary to close the device after plotting to ensure a valid file is written out.
C
A call to C<gplot()> looks like:
gplot({temp_plot_options}, # optional hash ref curve_options, data, data, ... , curve_options, data, data, ... );
The data entries are columns to be plotted. They are normally an optional ordinate and a required abscissa, but some plot modes can use more columns than that. The collection of columns is called a "tuple". Each column must be a separate PDL or an ARRAY ref. If all the columns are PDLs, you can add extra dimensions to make threaded collections of curves.
PDL::Graphics::Gnuplot also implements an object oriented interface. Plot objects track individual gnuplot subprocesses. Direct calls to C<gplot()> are tracked through a global object that stores globally set configuration variables.
The C<gplot()> sub (or the C<plot()> method) collects two kinds of
options hash: B
=head2 Basic plotting
Gnuplot generates many kinds of plot, from basic line plots and histograms to scaled labels. Individual plots can be 2-D or 3-D, and different sets of plot styles are supported in each mode. Plots can be sent to a variety of devices; see the description of plot options, below.
You can specify what type of graphics output you want, but in most cases doing nothing will cause a plot to be rendered on your screen: with X windows on UNIX or Linux systems, with an XQuartz window on MacOS, or with a native window on Microsoft Windows.
You select a plot style with the "with" curve option, and feed in columns of data (usually ordinate followed by abscissa). The collection of columns is called a "tuple". These plots have two columns in their tuples:
$x = xvals(51)-25; $y = $x*2; gplot(with=>'points', $x, $y); # Draw points on a parabola gplot(with=>'lines', $x, $y); # Draw a parabola gplot({title=>"Parabolic fit"}, with=>"yerrorbars", legend=>"data", $x, $y+(random($y)-0.5)2*$y/20, pdl($y/20), with=>"lines", legend=>"fit", $x, $y);
Normal threading rules apply across the arguments to a given plot.
All data are required to be supplied as either PDLs or array refs. If you use an array ref as a data column, then normal threading is disabled. For example:
$x = xvals(5); $y = xvals(5)**2; $labels = ['one','two','three','four','five']; gplot(with=>'labels',$x,$y,$labels);
See below for supported curve styles.
=head3 Modifying plots
Gnuplot is built around a monolithic plot model - it is not possible to add new data directly to a plot without redrawing the entire plot. To support replotting, PDL::Graphics::Gnuplot stores the data you plot in the plot object, so that you can add new data with the "replot" command:
$w=gpwin(x11); $x=xvals(101)/100; $y=$x; $w->plot($x,$y); $w->replot($x,$y*$y);
For speed, the data are not disconnected from their original variables - so this will plot X vs. sqrt(X):
$x = xvals(101)/100; $y = xvals(101)/100; $w->plot($x,$y); $y->inplace->sqrt; $w->replot();
=head3 Plotting to an image file or device
PDL:Graphics::Gnuplot can plot to most of the devices supported by gnuplot itself. You can specify the file type with the "output" method or the object constructor "gplot". Either one will allow you to name a type of file to produce, and a collection of options speciic to that type of output file.
=head3 Image plotting
Several of the plot styles accept image data. The tuple parameters work the same way as for basic plots, but each "column" is a 2-D PDL rather than a 1-D PDL. As a special case, the "with image" plot style accepts either a 2-D or a 3-D PDL. If you pass in 3-D PDL, the extra dimension can have size 1, 3, or 4. It is interpreted as running across (R,G,B,A) color planes.
=head3 3-D plotting
You can plot in 3-D by setting the plot option C
=head2 Enhanced text
Most gnuplot output devices include the option to markup "enhanced text". That means text is interpreted so that you can change its font and size, and insert superscripts and subscripts into labels. Codes are:
=over 3
=item {}
Text grouping - enclose text in braces to group characters, as in LaTeX.
=item ^
Superscript the next character or group (shrinks it slightly too where that is supported).
=item _
Subscript the next character or group (shrinks it slightly too where that is supported).
=item @
Phantom box (occupies no width; controls height for super- and subscripting)
=item &
Controllable-width space, e.g. &{template-string}
=item ~
overstrike -- e.g. ~a{0.8-} overprints '-' on 'a', raised by 0.8xfontsize.
=item {/[fontname][=fontsize | *fontscale] text}
Change font to (optional) fontname, and optional absolute font size or relative font scale ("fontsize" and "fontscale" are numbers). The space after the size parameter is not rendered.
=item \
Backslash escapes control characters to render them as themselves.
=back
=head2 Unicode text
Separately to "enhanced" text above, if you wish to include text that is not ASCII, then you will need to pass data that has been UTF-8 encoded. Sample code to achieve this:
use utf8; use Encode; use PDL; use PDL::Graphics::Gnuplot; use PDL::Constants qw(PI);
sub plotsin { my ($w, $coeff) = @; my $xrange = [ -2PI, 2PI ]; my $x = zeroes(1e3)->xlinvals(@$xrange); my $y = sin($coeff 2 PI $x); my $title = "y = sin( $coeff 2π * x )";
my $title_octets = encode('UTF-8', $title);
$w->plot(with=>'lines', $x, $y, {
xrange => $xrange,
title => $title_octets, # can not pass $title as-is
});
}
=head2 Color specification
There are several contexts where you can specify color of plot elements. In those places, you can specify colors exactly as in the Gnuplot manual, or more tersely. In general, a color spec can be any one of the following:
=over 3
=item - an integer
This specifies a recognizable unique color in the same order as used by the plotting engine.
=item - the name of a color
(e.g. "blue"). Supported color names are listed in the variable C<@Alien::Gnuplot::colors>.
=item - an RGB value string
Strings have the form C<#RRGGBB>, where the C<#> is literal and the RR, GG, and BB are hexadecimal bytes.
=item - the word "palette"
"palette" indicates that color is to be drawn from the scaled colorbar palette (which you can set with the "clut" plot option), by lookup using an additional column in the associated data tuple.
=item - the word "variable"
"variable" indicates that color is to be drawn from the integer plotting colors used by the plotting engine, indexed by an additional column in the associated data tuple.
=item - the phrase "rgb variable"
"rgb variable" indicates that color is to be directly specified by a 24 bit integer specifying 8-bit values for (from most significant byte to least significant byte) R, G, and B in the output color. The integer is drawn from an additional column in the associated data tuple.
=back
=head2 Plot styles supported
Gnuplot itself supports a wide range of plot styles, and all are supported by PDL::Graphics::Gnuplot. Most of the basic plot styles collect tuples of 1-D columns in 2-D mode (for ordinary plots), or either 1-D or 2-D "columns" in 3-D mode (for grid surface plots and such). Image modes always collect tuples made of 2-D "columns".
You can pass in 1-D columns as either PDLs or ARRAY refs. That is important for plot types (such as "labels") that require a collection of strings rather than numeric data.
Each plot style can by modified to support particular colors or line
style options. These modifications get passed in as curve options (see
below). For example, to plot a blue line you can use
C<with=E
The GNuplot plot styles supported are:
=over 3
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=item * C
=back
=head2 Options arguments
The plot options are parameters that affect the whole plot, like the title of
the plot, the axis labels, the extents, 2d/3d selection, etc. All the plot
options are described below in L<"Plot Options"|/"PLOT OPTIONS">. Plot options can be set
in the plot object, or passed to the plotting methods directly. Plot options can
be passed in as a leading interpolated hash, as a leading hash ref, or as a trailing
hash ref in the argument list to any of the main plotting routines (C
The curve options are parameters that affect only one curve in particular. Each
call to C<plot()> can contain many curves, and options for a particular curve
I
gplot( with => 'points', $x, $a, {axes=> x1y2}, $x, $b, with => 'lines', $x, $c );
This plots 3 curves: $a vs. $x plotted with points on the main y-axis (this is the default), $b vs. $x plotted with points on the secondary y axis, and $c vs. $x plotted with lines on the main y-axis (the default). Note that the curve options can be supplied as either an inline hash or a hash ref.
All the curve options are described below in L<"Curve Options"|/"CURVE OPTIONS">.
If you want to plot multiple curves of the same type without setting any curve options explicitly, you must include an empty hash ref between the tuples for subsequent lines, as in:
gplot( $x, $a, {}, $x, $b, {}, $x, $c );
=head2 Data arguments
Following the curve options in the C<plot()> argument list is the actual data being plotted. Each output data point is a "tuple" whose size varies depending on what is being plotted. For example if we're making a simple 2D x-y plot, each tuple has 2 values; if we're making a 3d plot with each point having variable size and color, each tuple has 5 values (x,y,z,size,color). Each tuple element must be passed separately. For ordinary 2-D plots, the 0 dim of the tuple elements runs across plotted point. PDL threading is active, so you can plot multiple curves with similar curve options on a normal 2-D plot, just by stacking data inside the passed-in PDLs. (An exception is that threading is disabled if one or more of the data elements is a list ref).
=head3 PDLs vs array refs
The usual way to pass in data is as a PDL -- one PDL per column of data in the tuple. But strings, in particular, cannot easily be hammered into PDLs. Therefore any column in each tuple can be an array ref containing values (either numeric or string). The column is interpreted using the usual polymorphous cast-behind-your-back behavior of Perl. For the sake of sanity, if even one array ref is present in a tuple, then threading is disabled in that tuple: everything has to have a nice 1-D shape.
=head3 Implicit domains
When making a simple 2D plot, if exactly 1 dimension is missing, PDL::Graphics::Gnuplot will use C<sequence(N)> as the domain. This is why code like C<plot(pdl(1,5,3,4,4) )> works. Only one PDL is given here, but the plot type ("lines" by default) requires 2 elements per tuple. We are thus exactly 1 ndarray short; C<sequence(5)> is used as the missing domain PDL. This is thus equivalent to C<plot(sequence(5), pdl(1,5,3,4,4) )>.
If plotting in 3d or displaying an image, an implicit domain will be used if we are exactly 2 ndarrays short. In this case, PDL::Graphics::Gnuplot will use a 2D grid as a domain. Example:
my $xy = zeros(21,21)->ndcoords - pdl(10,10); gplot({'3d' => 1}, with => 'points', inner($xy, $xy)); gplot( with => 'image', sin(rvals(51,51)) );
Here the only given ndarray has dimensions (21,21). This is a 3D plot, so we are exactly 2 ndarrays short. Thus, PDL::Graphics::Gnuplot generates an implicit domain, corresponding to a 21-by-21 grid.
C
=head2 Images
PDL::Graphics::Gnuplot supports four styles of image plot, via the "with" curve option.
The "image" style accepts a single image plane and displays it using the palette (pseudocolor map) that is specified in the plot options for that plot. As a special case, if you supply as data a (3xWxH) or (WxHx3) PDL it is treated as an RGB image and displayed with the "rgbimage" style (below), provided there are at least 5 pixels in each of the other two dimensions (just to be sure). For quick image display there is also an "image" method:
use PDL::Graphics::Gnuplot qw/image gplot/; $im = sin(rvals(51,51)/2); image( $im ); # display the image gplot( with=>'image', $im ); # display the image (longer form)
The colors are autoscaled in both cases. To set a particular color range, use the 'cbrange' plot option:
image( {cbrange=>[0,1]}, $im );
You can plot rgb images directly with the image style, just by including a 3rd dimension of size 3 on your image:
$rgbim = pdl( xvals($im), yvals($im),rvals($im)/sqrt(2)); image( $rgbim ); # display an RGB image gplot( with=>'image', $rgbim ); # display an RGB image (longer form)
Some additional plot styles exist to specify RGB and RGB transparent forms directly. These are the "with" styles "rgbimage" and "rgbalpha". For each of them you must specify the channels as separate PDLs:
gplot( with=>'rgbimage', $rgbim->dog ); # RGB the long way gplot( with=>'rgbalpha', $rgbim->dog, 255*($im>0) ); # RGBA the long way
According to the gnuplot specification you can also give X and Y values for each pixel, as in
gplot( with=>'image', xvals($im), yvals($im), $im )
but this appears not to work properly for anything more complicated than a trivial matrix of X and Y values.
PDL::Graphics::Gnuplot provides a "fits" plot style that interprets World Coordinate System (WCS) information supplied in the header of the scientific image format FITS. The image is displayed in rectified scientific coordinates, rather than in pixel coordinates. You can plot FITS images in scientific coordinates with
gplot( with=>'fits', $fitsdata );
The fits plot style accepts a curve option "resample" (which may be abbreviated), that allows you to downsample and/or rectify the image before it is passed to the Gnuplot back-end. This is useful either to cut down on the burden of transferring large blocks of image data or to rectify images with nonlinear WCS transformations in their headers. (gnuplot itself has a bug that prevents direct rendering of images in nonlinear coordinates).
gplot( with=>'fits', res=>1, $fitsdata ); gplot( with=>'fits', res=>[200], $fitsdata ); gplot( with=>'fits', res=>[100,400],$fitsdata );
to specify that the output are to be resampled onto a square 1024x1024 grid, a 200x200 grid, or a 100x400 grid, respectively. The resample sizes must be positive integers. A true non-ref value will be treated as 1024x1024.
=head2 Interactivity
Several of the graphical backends of Gnuplot are interactive, allowing
you to pan, zoom, rotate and measure the data interactively in the plot
window. See the Gnuplot documentation for details about how to do
this. Some terminals (such as C
Some interactive devices (notably C
=head1 PLOT OPTIONS
Gnuplot controls plot style with "plot options" that configure and
specify virtually all aspects of the plot to be produced. Plot
options are tracked as stored state in the PDL::Graphics::Gnuplot
object. You can set them by passing them in to the constructor, to an
C
Nearly all the underlying Gnuplot plot options are supported, as well as some additional options that are parsed by the module itself for convenience.
There are many, many plot options. For convenience, we've grouped
them by general category below. Each group has a heading "POs for E
=head2 POs for Output: terminal, termoption, output, device, hardcopy
You can send plots to a variety of different devices; Gnuplot calls
devices "terminals". With the object-oriented interface, you must set
the output device with the constructor C
C
C
For finer grained control of the plotting environment, you can send
"terminal options" to Gnuplot. If you set the terminal directly with
plot options, you can include terminal options by interpolating them
into a string, as in C
The routine C
=head2 POs for Titles
The options described here are
=over
=item title
=item xlabel
=item x2label
=item ylabel
=item y2label
=item zlabel
=item cblabel
=item key
=back
Gnuplot supports "enhanced" text escapes on most terminals; see "text", below.
The C
Individual plot components are labeled with the C
(Don't be confused by C
C
=over 3
=item * ( on | off ) - turn the key on or off
=item * ( inside | outside | lmargin | rmargin | tmargin | bmargin | at
These keywords set the location of the key -- "inside/outside" is
relative to the plot border; the margin keywords indicate location in
the margins of the plot; and at
=item * ( left | right | center ) ( top | bottom | center ) - horiz./vert. alignment
=item * ( vertical | horizontal ) - stacking direction within the key
=item * ( Left | Right ) - justification of plot labels within the key (note case)
=item * [no]reverse - switch order of label and sample line
=item * [no]invert - invert the stack order of the labels
=item * samplen
=item * spacing
=item * [no]autotitle - control whether labels are generated when not specified
=item * title "
=item * [no]enhanced - override terminal settings for enhanced text interpretation
=item * font "
=item * textcolor
=item * [no]box linestyle
=back
=head2 POs for axes, grids, & borders
The options described here are
=over
=item grid
=item xzeroaxis
=item x2zeroaxis
=item yzeroaxis
=item y2zeroaxis
=item zzeroaxis
=item border
=back
Normally, tick marks and their labels are applied to the border of a plot, and no extra axes (e.g. the y=0 line) nor coordinate grids are shown. You can specify which (if any) zero axes should be drawn, and which (if any) borders should be drawn.
The C
=over 3
=item *
The default if you set a true value for C
In three dimensions, 12 bits are used to describe the twelve edges of a cube surrounding the plot. In groups of three, the first four control the bottom (xy) plane edges in the same order as in the 2-D plots; the middle four control the vertical edges that rise from the clockwise end of the bottom plane edges; and the last four control the top plane edges.
=item * ( back | front ) - draw borders first or last (controls hidden line appearance)
=item * linewidth
These are Gnuplot's usual three options for line control.
=back
The C
To draw a coordinate grid with default values, set C<< grid=>1 >>. For more control, feed in an array ref with zero or more of the following parameters, in order:
The C
=head2 POs for axis range and mode
The options described here are
=over
=item xrange
=item x2range
=item yrange
=item y2range
=item zrange
=item rrange
=item cbrange
=item trange
=item urange
=item vrange
=item autoscale
=item logscale
=back
Gnuplot accepts explicit ranges as plot options for all axes. Each option accepts an array ref with (min, max). If either min or max is missing, then the opposite limit is autoscaled. The x and y ranges refer to the usual ordinate and abscissa of the plot; x2 and y2 refer to alternate ordinate and abscissa; z if for 3-D plots; r is for polar plots; t, u, and v are for parametric plots. cb is for the color box on plots that include it (see "color", below).
C
C
C
By default all axes are autoscaled unless you specify a range on that
axis, and partially (min or max) autoscaled if you specify a partial
range on that axis. C
autoscale=>{x=>'max',y=>'fix'};
There is an older array ref syntax which is deprecated but still accepted.
To not autoscale an axis at all, specify a range for it. The fix style of autoscaling forces the autoscaler to use the actual min/max of the data as the limit for the corresponding axis -- by default the axis gets extended to the next minor tic (as set by the autoticker or by a tic specification, see below).
C
=head2 POs for Axis tick marks
The options described here are
=over
=item xtics
=item x2tics
=item ytics
=item y2tics
=item ztics
=item cbtics
=item mxtics
=item mx2tics
=item mytics
=item my2tics
=item mztics
=item mcbtics
=back
Axis tick marks are called "tics" within Gnuplot, and they are extensively
controllable via the "{axis}tics" options. In particular, major and minor
ticks are supported, as are arbitrarily variable length ticks, non-equally
spaced ticks, and arbitrarily labelled ticks. Support exists for time formatted
ticks (see C
By default, gnuplot will automatically place major and minor ticks. You can turn off ticks on an axis by setting the appropriate {foo}tics option to a defined, false scalar value (e.g. C<< xtics=>0 >>). If you want to set major tics to happen at a regular specified intervals, you can set the appropriate tics option to a nonzero scalar value (e.g. C<< xtics=>2 >> to specify a tic every 2 units on the X axis). To use default values for the tick positioning, specify an empty hash or array ref (e.g. C<< xtics=>{} >>), or a string containing only whitespace (e.g. C<< xtics=>' ' >>).
If you prepend an 'm' to any tics option, it affects minor tics instead of major tics (major tics typically show units; minor tics typically show fractions of a unit).
Each tics option can accept a hash ref containing options to pass to
Gnuplot. You can also pass in a snippet of gnuplot command, as either
a string or an array ref -- but those techniques are deprecated and may
disappear in a future version of C
The keywords are case-insensitive and may be abbreviated, just as with other option types. They are:
=over 2
=item * axis - set to 1 to place tics on the axis (the default)
=item * border - set to 1 to place tics on the border (not the default)
=item * mirror - set to 1 to place mirrored tics on the opposite axis/border (the default, unless an alternate axis interferes -- e.g. y2)
=item * in - set to 1 to draw tics inward from the axis/border
=item * out - set to 1 to draw tics outward from the axis/border
=item * scale - multiplier on tic length compared to the default
If you pass in undef, tics get the default length. If you pass in a scalar, major tics get scaled. You can pass in an array ref to scale minor tics too.
=item * rotate - turn label text by the given angle (in degrees) on the drawing plane
=item * offset - offset label text from default position, (units: characters; requires array ref containing x,y)
=item * locations - sets tic locations. Gets an array ref: [incr], [start, incr], or [start, incr, stop].
=item * labels - sets tic locations explicitly, with text labels for each. If you specify both C
The labels should be a nested array ref that is a collection of duals or triplets. Each dual or triplet should contain [label, position, minorflag], as in C<< labels=>[["one",1,0],["three-halves",1.5,1],["two",2,0]] >>.
=item * format - printf-style format string for tic labels. There are some extensions to the gnuplot format tags -- see the gnuplot manual. Gnuplot 4.8 and higher have C<%h>, which works like C<%g> but uses extended text formatting if it is available.
=item * font - set font name and size (system font name)
=item * rangelimited - set to 1 to limit tics to the range of values actually present in the plot
=item * textcolor - set the color of the tick labels (see L</"Color specification">)
=back
For example, to turn on inward mirrored X axis ticks with diagonal Arial 9 text, use:
xtics => {axis=>1,mirror=>1,in=>1,rotate=>45,font=>'Arial,9'}
or
xtics => ['axis','mirror','in','rotate by 45','font "Arial,9"']
=head2 POs for time data values
The options described here are
=over
=item xmtics
=item x2mtics
=item ymtics
=item y2mtics
=item zmtics
=item cbmtics
=item xdtics
=item x2dtics
=item ydtics
=item y2dtics
=item zdtics
=item cbdtics
=item xdata
=item x2data
=item ydata
=item y2data
=item zdata
=item cbdata
=back
Gnuplot contains support for plotting absolute time and date on any of its axes, with conventional formatting. There are three main methods, which are mutually exclusive (i.e. you should not attempt to use two at once on the same axis).
=over 3
=item B
You can set any axis to plot timestamps rather than numeric values by setting the corresponding "data" plot option to "time", e.g. C<< xdata=>"time" >>. If you do so, then numeric values in the corresponding data are interpreted as UNIX time (seconds since the UNIX epoch, neglecting leap seconds). No provision is made for UTC<->TAI conversion. You can format how the times are plotted with the "format" option in the various "tics" options(above). Output specifiers should be in UNIX strftime(3) format -- for example, C<< xdata=>"time",xtics=>{format=>"%Y-%b-%dT%H:%M:%S"} >> will plot UNIX times as ISO timestamps in the ordinate.
Due to limitations within gnuplot, the time resolution in this mode is
limited to 1 second - if you want fractional seconds, you must use numerically
formatted times (and/or create your own tick labels using the C
B
Time format specifiers use the following printf-like codes:
=over 3
=item * B
=item * B
=item * B
=item * B
=item * B
=item * B
=item * B
=item * B<Am/pm>: C<%p> ("am" or "pm")
=item * B
=item * B
=item * B<Total seconds since start of 2000 A.D.>: C<%s>
=item * B
=item * B
=item * B
=back
=item B
If you just want to plot named days of the week, you can instead use
the C
=item B
The C
=back
=head2 POs for location/size
The options described here are
=over
=item tmargin
=item bmargin
=item lmargin
=item rmargin
=item offsets
=item origin
=item size
=item justify
=item clip
=back
Adjusting the size, location, and margins of the plot on the plotting surface is something of a null operation for most single plots -- but you can tweak the placement and size of the plot with these options. That is particularly useful for multiplots, where you might like to make an inset plot or to lay out a set of plots in a custom way.
The margin options accept scalar values -- either a positive number of
character heights or widths of margin around the plot compared to the
edge of the device window, or a string that starts with "at screen "
and interpolates a number containing the fraction of the plot window
offset. The "at screen" technique allows exact plot placement and is
an alternative to the C
The C
The C
The size option lets you adjust the size and aspect ratio of the plot,
as an absolute fraction of the plot window size. You feed in fractional
ratios, as in C<< size=>[$xfrac, $yfrac] >>. You can also feed in some keywords
to adjust the aspect ratio of the plot. The size option overrides any
autoscaling that is done by the auto-layout in multiplot mode, so use
with caution -- particularly if you are multiplotting. You can use
"size" to adjust the aspect ratio of a plot, but this is deprecated
in favor of the pseudo-option C
C
C
=head2 POs for Color: colorbox, palette, clut, pseudocolor, pc, perceptual, pcp
Color plots are supported via RGB and pseudocolor. Plots that use pseudcolor or grayscale can have a "color box" that shows the photometric meaning of the color.
The colorbox generally appears when necessary but can be controlled manually
with the C
=over 3
=item ( vertical | horizontal ) - indicates direction of the gradient in the box
=item ( default | user ) - indicates user origin and size
If you specify C
colorbox => [ 'user', 'origin'=>"$x,$y", 'size' => "$x,$y" ]
=item ( front | back ) - draws the colorbox before or after the plot
=item ( noborder | bdefault | border
The line style is a numeric type as described in the gnuplot manual.
=back
The C
For simple color maps, C
C
C
If you use C
=head2 POs for 3D: trid, view, pm3d, hidden3d, dgrid3d, surface, xyplane, mapping
If C
The C
The C
C
C
C
=head2 POs for Contour plots - contour, cntrparam
Contour plots are only implemented in 3D. To make a normal 2D contour plot, use 3-D mode, but set the view to "map" - which projects the 3-D plot onto its 2-D XY plane. (This is convoluted, for sure -- future versions of this module may have a cleaner way to do it).
C
C
=head2 POs for Polar plots - polar, angles, mapping
You can make 2-D polar plots by setting C
C
C
=head2 POs for Markup - label, arrow, object
You specify plot markup in advance of the plot command, with plot
options (or add it later with the C
To modify an object, you can specify it by number, either by appending
the number to the plot option name (e.g. C
To remove all objects of a given type, supply undef (e.g. C<< arrow=>undef >>).
For example, to place two labels, use the plot option:
label => [["Upper left",at=>"10,10"],["lower right",at=>"20,5"]];
To add a label to an existing plot object, if you don't care about what index number it gets, do this:
$w->options( label=>["my new label",at=>[10,20]] );
If you do care what index number it gets (or want to replace an existing label), do this:
$w->options( label=>[$n, "my replacement label", at=>"10,20"] );
where C<$w> is a Gnuplot object and C<$n> contains the label number you care about.
=head3 label - add a text label to the plot.
The C
Each label specifier array ref accepts the following suboptions, in order. All of them are optional -- if no options other than the index tag are given, then any existing label with that index is deleted.
For examples, please refer to the Gnuplot 4.4 manual, p. 117.
=over 3
=item
=item
You may supply double-quotes inside the string, but it is not
necessary in most cases (only if the string contains just an integer
and you are not specifying a
=item at
The
=item ( left | center | right ) - text placement rel. to position
=item rotate [ by
If "rotate" appears in the list alone, then the label is rotated 90 degrees CCW (bottom-to-top instead of left-to-right). The following "by" clause is optional.
=item font "
The
label3=>["foo",at=>"3,4",font=>'"Helvetica,18"']
=item noenhanced - turn off gnuplot enhanced text processing (if enabled)
=item ( front | back ) - rendering order (last or first)
=item textcolor
=item (point
=item offset
=back
=head3 arrow - place an arrow or callout line on the plot
Works similarly to the C
The arguments, all of which are optional but which must be given in the order listed, are:
=over 3
=item from
The
=item ( to | rto )
These work like C
=item (arrowstyle | as)
This specifies that the arrow be drawn in a particular predeclared numerical style. If you give this parameter, you should omit all the following ones.
=item ( nohead | head | backhead | heads ) - specify arrowhead placement
=item size
=item ( filled | empty | nofilled ) - specify arrowhead fill
=item ( front | back ) - specify drawing order ( last | first )
=item linestyle
=item linetype
=item linewidth
=back
=head3 object - place a shape on the graph
C
The arguments, all of which are optional but which must be given in the order listed, are:
=over 3
=item
The
You can specify a rectangle with C<< from=>$pos1, [r]to=>$pos2 >>, with C<< center=>$pos1, size=>"$w,$h" >>, or with C<< at=>$pos1,size=>"$w,$h" >>.
You can specify an ellipse with C<< at=>$pos, size=>"$w,$h" >> or C<< center=>$pos, size=>"$w,$h" >>, followed by C<< angle=>$a >>.
You can specify a circle with C<< at=>$pos, >> or C<< center=>$pos, >>, followed by C<< size=>$radius >> and (optionally) C<< arc=>"[$begin:$end]" >>.
You can specify a polygon with C<< from=>$pos1,to=>$pos2,to=>$pos3,...to=>$posn >> or with C<< from=>$pos1,rto=>$diff1,rto=>$diff2,...rto=>$diffn >>.
=item ( front | back | behind ) - draw the object last | first | really-first.
=item fc
=item fs
=item lw
=back
=head2 POs for appearance tweaks - bars, boxwidth, isosamples, pointsize, style
B<C
=over 3
=item * A width specifier, which should be a numeric size multiplier times the usual
width (which is about one character width in the default font size), or the word
C
=item * the word "front" or "back" to indicate drawing order in plots that might contain filled rectangles (e.g. boxes, candlesticks, or histograms).
=back
If you pass in the undefined value you get no ticks on errorbars; if you pass in the empty array ref you get default ticks.
B<C
=over 3
=item * a numeric width
=item * one of the words C
=back
Unless you set C
B<C
B<C
B<C