I am trying to create a png from a matrix using the pngcairo terminal, where each entry in the matrix is the colour of a single pixel in the image. For that purpose, I remove the border, tics, labels etc.
However, it seems that terminal always assumes the border takes the space of the first layer of pixels around the image and doesn't plot the data there, or does something funny there (antialiasing? I don't think so because it doesn't do the same blue smudge inside the image).
Here is a MWE (using transparent to highlight the issue):
set term pngcairo transparent size 7, 7
set margins 0,0,0,0
unset border
unset xtics
unset ytics
unset xlabel
unset ylabel
unset colorbox
unset key
set palette defined (0 "white", 1 "blue") maxcolors 2
set output 'test.png'
set xrange [0:6]
set yrange [0:6]
plot '-' matrix with image notitle
1 1 1 1 1 1 1
1 1 1 0 1 1 1
1 1 0 0 0 1 1
1 0 0 0 0 0 1
1 1 0 0 0 1 1
1 1 1 0 1 1 1
1 1 1 1 1 1 1
e
unset output
The result is a 7x7 pixel image whose magnification (using an image viewer with checkerboard background) is
What I would expect instead is
which is obtained by creating a 70x70 pixel image, offsetting the origin by 0.5 along each axis
using (0.5+$1):(0.5+$2):3
, and extending the xrange
and yrange
to [0:7]
. You will note that there is still a 1 pixel layer of background around the image, where the data is not plotted.
Is there any way to use the data from the matrix to plot on the border using this terminal?
I am using Gnuplot 5.4 patchlevel 2