0
votes

I have a data file that I would like to plot as a heatmap. There are 3 columns: x, y, and the count at point (x,y). The problem is that the bins have different sizes in y (and not in x), for example

-0.3    0       0
-0.3    6.7082  0
-0.3    8.66025 0
-0.3    10.247  0
-0.3    11.619  0
-0.3    12.8452 0
...

But when I plot using for example

set view map
set size ratio -1
set key off
splot "histo.txt" u 1:2:3 w image

I get an image in which the bin sizes in the y direction are the same, thus the picture is distorted. How can I plot a heatmap with different bin sizes in one direction? I also know exactly where each bin should begin and end in y, the values in the second column of the data file are a weigthed average.

Thank you.

1
with image plots a pixel image, with a regular pixel grid. Try pm3d, and read the docs for pm3d interpolate and pm3d corners2color to understand how that works.Christoph
Thank you, that worked (after fixing the blank lines in the data file).Francesco

1 Answers

0
votes

Gnuplot offers basically two plotting styles suitable for heat maps, pm3d and image, which however have very different behaviour:

image:

  • Draws a pixel image
  • Always uses a regular grid, no matter what x or y values are used
  • Each quadrangle (here, the pixel) is centered on one data point

pm3d:

  • Draws vectorial quadrangles
  • Can use irregular grids with varying spacings
  • Draws each quadrangle with four data points as corners. The color is by default given by the mean value of those four points, that can be changed with set pm3d corners2color ...
  • Can interpolate
  • Many more features, applicable for 3d etc

So, to summarize: image can be used for heat maps and has its advantages, but in your case you need pm3d, which offers you the flexibility, you need.