Reputation: 73
I am trying to plot some data as a heat map in gnuplot. My data is a ".txt" file with three columns. The first two columns are the independent variables and the third is the output. E.g, a simplified example:
0.00 0.00 11.9
0.00 0.50 0.01
0.50 0.00 4.5
0.50 0.50 20.0
gnuplot> set view map; set dgrid3d; splot "output.txt" using 1:2:3 with pm3d
I expect to get a 2*2 array of squares with colours according to their value. Instead, I think gnuplot has interpolated the values as regardless of my initial number of data points, it plots a 9*9 array of squares with shading. How can I just plot the data I have with no interpolation? output from gnuplot
Upvotes: 3
Views: 2543
Reputation: 1731
I think what you're looking for is plot ... with image pixels
. The script below generates a png file with only 4 pixels, colored by their z-value:
#!/bin/bash
echo "0.00 0.00 11.9
0.00 0.50 0.01
0.50 0.00 4.5
0.50 0.50 20.0" > output.txt
gnuplot << GNUPLOT
set term png
set out "output.png"
plot "output.txt" using 1:2:3 with image pixels
GNUPLOT
rm output.txt
The output.png
file should behave the way you expect (hopefully)!
You can also tweak the cbtics to print only the values on the third column. I would also suggest looking at these two gnuplot
man pages:
Upvotes: 6