PDL-Graphics-Simple
view release on metacpan or search on metacpan
hold;
line($x, sqrt($y)*10);
release;
=item * Justify aspect ratio
imag $im, {justify=>1}
points($x, $y, {justify=>1});
=item * Erase/delete the plot window
erase();
=back
=head2 Simple object-oriented plotting
More functionality is accessible through direct use of the PDL::Graphics::Simple
object. You can set plot size, direct plots to files, and set up multi-panel plots.
The constructor accepts window configuration options that set the plotting
environment, including size, driving plot engine, output, and multiple
panels in a single window.
For interactive/display plots, the plot is rendered immediately, and lasts until
the object is destroyed. For file plots, the file is not guaranteed to exist
and be correct until the object is destroyed.
The basic plotting method is C<plot>. C<plot> accepts a collection of
arguments that describe one or more "curves" (or datasets) to plot,
followed by an optional plot option hash that affects the entire plot.
Overplotting is implemented via plot option, via a held/released state
(as in PGPLOT), and via a convenience method C<oplot> that causes the
current plot to be overplotted on the previous one.
Plot style (line/points/bins/etc.) is selected via the C<with> curve option.
Several convenience methods exist to create plots in the various styles.
=over 3
=item * Load module and create basic objects
use PDL::Graphics::Simple;
$x = xvals(51)/5;
$y = $x**3;
$win = pgswin(); # plot to a default-shape window
$win = pgswin( size=>[4,3] ); # size is given in inches by default
$win = pgswin( size=>[10,5,'cm'] ); # You can feed in other units too
$win = pgswin( out=>'plot.ps' ); # Plot to a file (type is via suffix)
$win = pgswin( engine=>'gnuplot' ); # Pick a particular plotting engine
$win = pgswin( multi=>[2,2] ); # Set up for a 2x2 4-panel plot
=item * Simple plots with C<plot>
$win->plot( with=>'line', $x, $y, {title=>"Simple line plot"} );
$win->plot( with=>'errorbars', $x, $y, sqrt($y), {title=>"Error bars"} );
$win->plot( with=>'circles', $x, $y, sin($x)**2 );
=item * Plot overlays
# All at once
$win->plot( with=>'line', $x, $y, with=>'circles', $x, $y/2, sqrt($y) );
# Using oplot (IDL-style; PLplot-style)
$win->plot( with=>'line', $x, $y );
$win->oplot( with=>'circles', $x, $y/2, sqrt($y) );
# Using object state (PGPLOT-style)
$win->line( $x, $y );
$win->hold;
$win->circles( $x, $y/2, sqrt($y) );
$win->release;
=back
=head1 FUNCTIONS
=cut
=head2 show
=for usage
PDL::Graphics::Simple::show
=for ref
C<show> lists the supported engines and a one-line synopsis of each.
=cut
=head2 pgswin - exported constructor
=for usage
$w = pgswin( %opts );
=for ref
C<pgswin> is a constructor that is exported by default into the using package. Calling
C<pgswin(%opts)> is exactly the same as calling C<< PDL::Graphics::Simple->new(%opts) >>.
=head2 new
=for usage
$w = PDL::Graphics::Simple->new( %opts );
=for ref
C<new> is the main constructor for PDL::Graphics::Simple. It accepts a list of options
about the type of window you want:
=over 3
=item engine
If specified, this must be one of the supported plotting engines. You
can use a module name or the shortened name. If you don't give one,
( run in 1.619 second using v1.01-cache-2.11-cpan-39bf76dae61 )