Here\'s an interesting problem:
I have a 2D \"matrix\" of double-precision, binary data I\'d like to plot using Gnuplot. This is easily done as follows:
You can achieve that by giving the respective pixel a value of 'NaN':
value = 123456789.0
plot "foo.dat" binary array=384x384 format='%double' \
using ($1 == val ? NaN : $1) with image
Note, that this depends on the selected terminal. It works at least with wxt
, pdfcairo
, pngcairo
and png
, and does not work with x11
and postscript
. I didn't test other terminals.
Here is a self-contained example. The background color is set to show that the pixel indeed is transparent and not white:
set xrange [0:1]
set yrange [0:1]
set isosamples 11
set samples 11
plot '++' using 1:2:($1 == 0.5 && $2 == 0.5 ? NaN : $1) with image
The result with 4.6.5 is:
Using your example data file, the following script works fine and gives a nice result:
set terminal pngcairo size 800,800
set output 'foo.png'
set size square
f(x)=1.5-4*abs(x)
set palette model RGB
set palette functions f(gray-0.75),f(gray-0.5),f(gray-0.25)
val = 1234567890.0
set autoscale xfix
set autoscale yfix
set cbrange [-10000:10000]
plot 'foo.dat' binary array=(512,512) format='%double' using ($1 == val ? NaN : $1) with image notitle