3
votes

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:

enter image description here

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

enter image description here

Any ideas how to solve this?

I am using gnuplot 5.0

Thank you for your help.

1
I realize this does not help you much, but given that gnuplot is designed for plotting charts, I think that attempting to plot to a 3x3 image is a misuse of the software and does not suit it's intentions.d3dave
I just tried this, and an image of size 7x7 appears to be the minimum size that does not leave a residual white line. Consider increasing your image size.d3dave
The 3x3 image is an example to demonstrate the effect, to make it as simple as possible. The image itself shows scientific data, a vector field of typically 400x80 pixels size. I like gnuplot because I can also add arrows and save it as a vector graphics, e.g., pdf. If you know any other software that does this job, please let me know.Felix
Here you find the data I would like to plot: filedropper.com/testdata It is 400x80 px large and gnuplot draws a white pixel line in the bottom. Most importantly, this line comes at a loss of the top pixel line.Felix
I would suggest asking this question on the Gnuplot info mailinglist.Thor

1 Answers

2
votes

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.