2

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.

zubenel
  • 300
  • 4
  • 10
  • 2
    The choice of colors affects our perception. – brian d foy Mar 01 '20 at 17:12
  • 1
    Which backend did `PDL::Graphics::Simple` use? There should be terminal output describing the backend. On my machine I got output: `Trying gnuplot (PDL::Graphics::Gnuplot)...ok` so it used the `PDL::Graphics::Gnuplot` backend. – Håkon Hægland Mar 01 '20 at 19:54
  • The problem was to make this example to work on Windows. I was able to do it with `PDL::Graphics::Gnuplot` directly but not with `PDL::Graphics::Simple`. Because of that I compare the image I got to the one that is shown in PDL book. – zubenel Mar 01 '20 at 20:16
  • How did you install `gnuplot` on Windows? – Håkon Hægland Mar 01 '20 at 23:24
  • 1
    I installed Strawberry Perl with PDL version 5.30. Apparently it contains Gnuplot as I get no error with `use PDL::Graphics::Gnuplot;`. – zubenel Mar 02 '20 at 05:09

1 Answers1

2

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.

Ed.
  • 1,992
  • 1
  • 13
  • 30