5

I draw a spectrogram with gnuplot version 4.6. I ensured it is the newest version here: http://www.gnuplot.info/download.html

Gnuplot is installed from Debian repository.

The plot area and the scale on the right includes strange white lines. They seem to separate the data. On plot area with dense data they look like checkered pattern:

http://imageshack.us/a/img822/6219/linese.png

Lines are less visible on the scale but also they are there. There are only horizontal lines on the scale.

I thought it's the case of monitor gamut or something but lines occur also with pdf monochrome.

My code is:

#!/usr/bin/gnuplot

set term pdf
# set style fill noborder # checked with and without this line
set output "../results1/fft.pdf"
set pm3d map
splot "../results1/fft.dat"

As you can read there I tried using option noborder but both with and without the lines exist.

Example data can be:

0 1 3
0 2 3
0 3 4
0 4 2
0 5 2
0 6 3
0 7 4
0 8 3

1 1 3
1 2 2
1 3 4
1 4 2
1 5 2
1 6 3
1 7 4
1 8 4

2 1 2
2 2 4
2 3 4
2 4 3
2 5 2
2 6 4
2 7 2
2 8 2

3 1 2
3 2 3
3 3 3
3 4 4
3 5 2
3 6 2
3 7 2
3 8 2

Do you have any idea how to get rid of this lines?

nuoritoveri
  • 2,494
  • 1
  • 24
  • 28

2 Answers2

2

This has plagued me for some time as well. The best workaround I have is inspired by this post. Basically you can use

plot "datafile" with image

instead of the splot command. There are some subtle differences in how the data is plotted, but this creates a .pdf without those nasty gaps between the colored areas, and a much smaller file.

Note this only really works for data which forms a rectangular grid! If the datafile is in a matrix format (no x or y data except for the number of data points) which for your example would be

3 3 2 2
3 2 4 3
...

(z-value from first row of each block makes the first row, etc.) you can use the command

plot 'datafile' ($1*xincr - x0):($2*yincr - y0):3 matrix with image

The stuff in parens is optional, but allows you to scale the resulting plot to the correct x and y values. (xincr is a gnuplot variable you would have to set for the x-increment in the data, x0 is the x offset, etc.)

If this results in a white gap around the plot, use the plot command once, rescale the axes, and plot again, e.g.

set terminal unknown
plot 'datafile' ($1*xincr - x0):($2*yincr - y0):3 matrix with image
set xr[GPVAL_DATA_X_MIN:GPVAL_DATA_X_MAX]
set yr[GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX]
set output "fft.pdf"
replot

Second answer

I find that this effect is pdf-viewer-dependent. For instance, it shows up in evince under linux but not okular. Depending on your application you could just use a different viewer.

andyras
  • 15,542
  • 6
  • 55
  • 77
  • Thanks for the answer and additional tips on scales. I installed okular to check and white lines are still there. I will now experiment with the first solution, at first try there are still lines on the scale but I'm not sure if I really have to use the scale. – nuoritoveri Oct 01 '12 at 20:31
  • Yes, I have had trouble getting rid of the lines in the colorbar. That is one instance where using okular helped, I think. Adobe reader may also have shown a smooth colorbar. Of course there is always the `png` terminal which doesn't have this problem... – andyras Oct 01 '12 at 22:48
0

For me, replacing

set pm3d map

with

unset surface; set pm3d at b; set view map

corrects this problem. Tested on gnuplot 4.6 patchlevel 2 and gnuplot 5.4 patchlevel 1.

I can't give much insight as to why, but the manual reveals that

set pm3d map

is a shortcut for

 set pm3d at b; set view map; set style data pm3d; set style func pm3d

Simple testing reveals that the problem occurs if either of the "set style" instructions are included. Their removal corrects the problem, but leaves the surface visible - hence "unset surface".