Question

I'm quite unexperienced with gnuplot. I was working with the demos on this site: http://gnuplot.sourceforge.net/demo/heatmaps.html

I managed to get a heatmap with:

set title "Heat Map"
unset key
set tic scale 0

set palette rgbformula 30,31,32
set cbrange [0:40]
set cblabel "Compactness"
unset cbtics

set xrange [-0.5:105.5]
set yrange [-0.5:27.5]

set view map
set terminal gif
set output "heatmap.gif"
splot '-' matrix with image

But as in the example this produces rectangles. How can I make gnuplot plot quadratic fields/pixels/points?

Was it helpful?

Solution

There is no need to use splot for a heatmap. Just use plot ... with image. For a 2D plot you can use set size ratio -1 to have the same units on both axes.

Consider the test data file test.dat:

1 2 3 4 3 4 5 6 7
4 5 6 3 9 8 2 9 4

With the minimal script

set terminal pngcairo
set output 'test.png'

set autoscale fix
set size ratio -1
set palette rgbformulae 30,31,32
plot 'test.dat' matrix with image

you get the result (with 4.6.3):

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top