perlgnuplotpdl

"First steps with PDL" image created with Gnuplot differs from the one in PDL Book


I found an example from http://pdl.perl.org/?page=FirstSteps that is:

pdl> use PDL::Graphics::Simple
pdl> imag (sin(rvals(200,200)+1)

I tried to run this example but unsuccessfully. As a consequence to that I tried to adjust the example that it would work with Gnuplot on Windows:

pdl> use PDL::Graphics::Gnuplot;
pdl> gplot(with => 'image', sin(rvals(200,200)+1) );

However, the resulting plot differs from the one that is given in PDL Book as it contains additional "V" form blue stripes:

enter image description here

For comparison image from PDL Book looks much cleaner:

enter image description here

I do not know what caused the difference.


Solution

  • I have just tried this with Gnuplot 5.2, bleeding-edge PDL, latest PDL::Graphics::Gnuplot (PGG) and PDL::Graphics::Simple (PGS). I get the same results as you for PGG, and for the book with PGS.

    The way to make the colour-scheme be the same in both is to change the Gnuplot invocation to supply plot-options first:

    pdl> use PDL::Graphics::Gnuplot
    pdl> gplot({clut => 'sepia', colorbox => '', justify =>1}, with => 'image', sin(rvals(200,200)+1))
    

    since, for better or for worse, PGS defaults to a sepia-tone. The colorbox option is the colour-scale, and if it's not there and you want the data to still be square, you have to add a true justify value.