I would like to plot image data using gnuplot, without any border, tics, etc. Just the image. Unfortunately, gnuplot always draws the bottom line white. Here is an example of what should result in an entirely black 3x3 pixel image:
set term png size 3,3
set out 'test.png'
set xrange [0:2]
set yrange [0:2]
unset xlabel
unset ylabel
set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0
set size ratio -1
unset xtics
unset ytics
set border 0
unset key
p '-' w rgbimage
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
0 1 0 0 0
1 1 0 0 0
2 1 0 0 0
0 2 0 0 0
1 2 0 0 0
2 2 0 0 0
e
The result is a picture with one white line and 2 black pixel lines:

Here is a magnified screenshot with a gray frame of the image viewer:

Any ideas how to solve this?
I am using gnuplot 5.0
Thank you for your help.
I think having a 3px times 3px image is not a proper use case. Of course, representing a 3x3 data matrix is perfectly valid!
Seems, like there are some problems when plotting pixel-based data with some terminals. Since you said, that in the end you want to have a vector image (which would in any case affect only some arrows you draw on top of the pixel-data), I had a look at some vector formats only, using your example testdata.dat and the script testdata.gp
set autoscale xfix
set autoscale yfix
set margins 0,0,0,0
unset xtics
unset ytics
unset border
unset key
p 'testdata.dat' w rgbimage
pdfcairo doesn't work, has some boundary artifacts.postscript works fine, I used
set terminal postscript eps level3 size 8cm,1.6cm
set output 'testdata.eps'
load 'testdata.gp'
set output
system('epstopdf testdata.eps')
tikz works fine as well:
set terminal tikz standalone externalimages size 8cm,1.6cm
set output 'testdata.tex'
load 'testdata.gp'
set output
system('pdflatex testdata.tex')
svg works fine:
set terminal svg standalone size 800,160
set output 'testdata.svg'
load 'testdata.gp'
I don't know yet, what the actual problem with the cairo terminals is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With