Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
569 views
in Technique[技术] by (71.8m points)

gnuplot - Reduce distance between points in splot

I have this gnuplot script

reset
set palette model RGB defined (0 "gray", 0.1 "white", 0.33 "yellow", 0.66 "orange", 1 "red")
set xlabel "x"
set ylabel "y"
set view map
set border 0
unset xtics
unset ytics
splot file_name u 1:2:5:xtic(3):ytic(4) w points ps 5 pt 5 palette

And this is the result:

heatmap

How can I remove the distance between the points so that I end up with a set of adjacent squares? I want to plot a heatmap with a square for each point in my grid file.

EDIT

The correct way to plot a "grid" heatmap as per @andyras answer is:

set pm3d map
plot file_name u 1:2:5:xtic(3):ytic(4) with image

Which gives this image:

Grid heatmap

gnuplot offers a third way to plot a heatmap based on connecting points of a 3d surface, rather than grid cells. That is, the x,y coordinates at columns 1,2 are used as corners, or connecting points, of a surface mesh and the colors used in each region are the average of the RGB/HSV values for the 4 defining corners:

set pm3d map
splot file_name u 1:2:5:xtic(3):ytic(4)

3d heatmaps with top view

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I usually go with the options

set pm3d map
plot file_name u 1:2:5:xtic(3):ytic(4) with image

for gridded data (it makes a smaller file if you use vector formats). I suspect your problem may be to do with the fact that you specify a point style and size for your splot. So, you could try setting the pm3d map option and using splot without the point specification, or plot ... with image.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...