pablo
pablo

Reputation: 385

Heatmap of points in a volume

I have (x,y,z) points with coordinates like the following figure,

enter image description here

I would like to color the points based on their concentration. The idea is to make a heatmap of points but in a 3D figure.

I would appreciate very much any help possible.

Regards.

Upvotes: 0

Views: 399

Answers (2)

Ethan
Ethan

Reputation: 15093

The gnuplot development version now supports calculation of a point density function that can in turn be used to color individual points. This depends on a new set of commands that operate on a 3D grid of voxels. Sample script and output:

set title "Gaussian 3D cloud of 3000 random samples\ncolored by local point density"
rlow = -4.0; rhigh = 4.0
set xrange [rlow:rhigh]; set yrange [rlow:rhigh]; set zrange [rlow:rhigh]
set xtics axis nomirror; set ytics axis nomirror; set ztics axis nomirror;
set xyplane at 0
set xzeroaxis lt -1; set yzeroaxis lt -1; set zzeroaxis lt -1;
set log cb; set cblabel "point density"

# define 100 x 100 x 100 voxel grid
set vgrid $vdensity size 100
vclear $vdensity    

# datablock $random has previously been loaded with 3000 points
# in a spherical Gaussian distribution about the origin
# The vfill command adds 1 to each voxel in a spherical region with radius 0.33
# around each point in $random
vfill $random using 1:2:3:(0.33):(1.0)

# plot the same points colored by local point density
splot $random using 1:2:3:(voxel($1,$2,$3)) with points pt 7 ps 0.5 lc palette

enter image description here

Full demo here: voxel demo in gnuplot online collection

Upvotes: 0

Ethan
Ethan

Reputation: 15093

Use data values in a 4th column to index a smooth color palette

splot DATA using 1:2:3:4 with points lc palette

Upvotes: 1

Related Questions