PDLA-Rest
view release on metacpan or search on metacpan
Demos/Gnuplot_demo.pm view on Meta::CPAN
$w->plot( {title=>"Points and lines mixed"},
with=>'points', le=>'sin (points)', $x, $y,
with=>'lines', le=>'cos (line)', $x, $y2);
|;
act q|
# Many types of plot are supported, using the "plot" command
# and the "with" curve option. Here, we can mix and match points and lines.
$w->plot( with=>'points', le=>'sin (points)', $x, $y,
with=>'lines', le=>'cos (line)', $x, $y2);
$x = xvals(51)/50;
($y,$y2) = ( $x * sin(20 * $x), sqrt($x) * cos(20 * $x) );
$radii = 0.01 * (0.25 - ($x*2 - 0.5)**2);
# Here are some other options.
$w->plot( {title=>"Circles and Steps"},
le=>"Circles", with=>'circles', $x, $y, $radii,
le=>"Steps", with=> 'steps', $x, $y2
);
|;
act q|
# You can plot multiple plots on one pane with "multiplot".
$x = xvals(51)/50;
($y,$y2) = ( $x * sin(20 * $x), sqrt($x) * cos(20 * $x) );
$w->multiplot(layout=>[1,2]);
$w->plot( {title=>"Impulses"}, with=> 'impulses', $x, $y );
$w->plot( {title=>"Filled Curves"}, with => "filledcurves", $x, $y, $y2 );
$w->end_multi();
|;
act q|
# 2-D data...
$rv = rvals(51,51)/2;
$im = 25 * cos($rv) / ($rv+1.5);
$w->multiplot(layout=>[2,2]);
$w->options(justify=>1); # set nice aspect ratio
$w->plot( {tit=>'Default color map'}, with=>'image', $im );
$w->plot( {tit=>'Grayscale', clut=>'gray'}, with=>'image', $im );
$w->plot( {tit=>'heat map', clut=>'heat1'}, with=>'image', $im );
$w->plot( {tit=>'3d perspective', trid=>1}, with=>'pm3d', $im );
$w->end_multi;
|;
act q|
# You can indpendently specify color and position on surface plots,
# and can overlay multiple types of plot -- even in 3D.
#
$rv = rvals(101,101)/5; $im = cos($rv)/($rv+2.5);
$grad = sumover $im->range([[-1,0],[1,0]],[$im->dims],'e') * pdl(-1,1);
$im2 = $im->indexND(ndcoords(26,26)*4); # subsample $im
$w->reset;
$w->options( trid=>1, hidden=>'front', colorbox=>0, clut=>'heat1' );
$w->multiplot(layout=>[2,2]);
$w->plot( {title=>"A colormap-shaded 3-d surface plot"}, with=>'pm3d', $im );
$w->plot( {title=>"Perspective 3-d surface plot"},
with=>'pm3d', xvals($im), yvals($im), $im, $grad );
$w->plot( {title=>"Perspective grid plot"},
with=>'lines', xvals($im2)*4, yvals($im2)*4, $im2 );
$w->plot( {title=>"Combined"},
with=>'pm3d', xvals($im),yvals($im), $im, $grad,
with=>'lines', xvals($im2)*4, yvals($im2)*4, $im2 );
$w->end_multi;
|;
use File::Spec;
$d = File::Spec->catdir( "PDLA", "Demos" );
$m51path = undef;
foreach my $path ( @INC ) {
my $check = File::Spec->catdir( $path, $d );
if ( -d $check ) { $m51path = $check; last; }
}
if( defined($m51path) && -e "$m51path/m51.fits") {
$m51path = "$m51path/m51.fits";
} else {
comment q|
******************************************************
You seem to be missing the file 'm51.fits', which
should be included in the PDLA distribution. Without
it, I can't show you the m51 image demos, so I'll
quit now.
******************************************************
|;
return;
}
$s = q|
# Images ...
$m51 = rfits('%%m51%%');
$w->reset;
$w->image({j=>1, clut=>'gray', title=>"M51 galaxy"}, with=>'image',$m51 );
|;
$s=~ s/\%\%m51\%\%/$m51path/;
( run in 2.070 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )