如何使用 gnuplot 将 4d 数据绘制成热图
How to plot 4d data into heatplot using gnuplot
请帮忙!
我有一个格式为
的数据集
x y z p
-0.574142 -0.818671 0.011756 0.000440
-0.364919 0.184603 0.912555 0.000324
-0.990822 -0.022168 0.133345 0.000419
-0.983317 -0.089955 0.158099 0.000417
-0.493497 0.474422 -0.728961 0.000501
-0.789287 -0.566719 0.236336 0.000413
0.293932 0.520691 -0.801551 0.000510
并且它们是 3d 球体上的随机点,p 值(第四列)代表该位置的“热量”,实际数据文件有 50 个这样的点。
我想将球体的表面绘制成热图,而不是每个点都被着色。
我搜索了很多 post,所有这些都需要某种等值线,但就我而言,没有。是否仍然可以使用 gnuplot 来做热图?我也对任何其他方式开放。
btw im 运行 linux 使用最新的 gnuplot,数据由 c
生成
ps:我知道有一种方法可以将数据制作成等值线,然后将 gnuplot 与 pm3d 一起使用,但我不能这样做,因为我所有的 x 数据都是随机的,因此没有等值线。
注意:此答案仅与最新的 gnuplot 5.4 版本相关
Gnuplot 5.4 版可以在 3D 网格 space 体素中工作,体素值可用于保存第 4 维数据。即体素(x,y,z)= 值
这是一个非常新的功能,可以改进,所以你的问题可以作为一个很好的例子来说明它现在可以做什么和不能做什么。
$data << EOD
x y z p
-0.574142 -0.818671 0.011756 0.000440
-0.364919 0.184603 0.912555 0.000324
-0.990822 -0.022168 0.133345 0.000419
-0.983317 -0.089955 0.158099 0.000417
-0.493497 0.474422 -0.728961 0.000501
-0.789287 -0.566719 0.236336 0.000413
0.293932 0.520691 -0.801551 0.000510
EOD
#
# Generate a heatmap on the surface of a sphere
#
set view equal xyz
set view 78, 246
set xyplane at 0
unset key
set xtics ("x" 0); set ytics ("y" 0); set ztics ("z" 1)
set hidden3d # only relevant to axis tics and labels
#
# Use spherical mapping to generate a set of points describing the surface.
# Then return to Cartesian coordinates to handle voxels.
#
set mapping spherical
set angle degrees
set samples 51
set isosamples 101
set urange [-90:90]
set vrange [0:360]
set table $surface
splot '++' using 1:2:(1.0) with points
unset table
set mapping cartesian
# define 100 x 100 x 100 voxel grid
rlow = -1.1; rhigh = 1.1
set xrange [rlow:rhigh]; set yrange [rlow:rhigh]; set zrange [rlow:rhigh]
set vgrid $vdensity size 100
vclear $vdensity
# mark voxels in a spherical region with radius <near> around each point in $data
# Note that values are summed rather than averaged
near = 0.1
vfill $data skip 1 using 1:2:3:(near):()
show vgrid
# color range should be found automatically but it isn't
set cbtics
set colorbox user origin screen 0.8, screen 0.2
set cbrange [ 0 : 0.001 ]
set palette cubehelix negative # colors from cbmin white -> cbmax dark
set pm3d depthorder
set pm3d lighting primary 0.4 specular 0.1
set title "Sphere surface is colored by the value of the nearest point[s] in $data"
splot $surface using 1:2:3:(voxel(,,)) with pm3d
请帮忙! 我有一个格式为
的数据集x y z p
-0.574142 -0.818671 0.011756 0.000440
-0.364919 0.184603 0.912555 0.000324
-0.990822 -0.022168 0.133345 0.000419
-0.983317 -0.089955 0.158099 0.000417
-0.493497 0.474422 -0.728961 0.000501
-0.789287 -0.566719 0.236336 0.000413
0.293932 0.520691 -0.801551 0.000510
并且它们是 3d 球体上的随机点,p 值(第四列)代表该位置的“热量”,实际数据文件有 50 个这样的点。
我想将球体的表面绘制成热图,而不是每个点都被着色。
我搜索了很多 post,所有这些都需要某种等值线,但就我而言,没有。是否仍然可以使用 gnuplot 来做热图?我也对任何其他方式开放。
btw im 运行 linux 使用最新的 gnuplot,数据由 c
生成ps:我知道有一种方法可以将数据制作成等值线,然后将 gnuplot 与 pm3d 一起使用,但我不能这样做,因为我所有的 x 数据都是随机的,因此没有等值线。
注意:此答案仅与最新的 gnuplot 5.4 版本相关
Gnuplot 5.4 版可以在 3D 网格 space 体素中工作,体素值可用于保存第 4 维数据。即体素(x,y,z)= 值 这是一个非常新的功能,可以改进,所以你的问题可以作为一个很好的例子来说明它现在可以做什么和不能做什么。
$data << EOD
x y z p
-0.574142 -0.818671 0.011756 0.000440
-0.364919 0.184603 0.912555 0.000324
-0.990822 -0.022168 0.133345 0.000419
-0.983317 -0.089955 0.158099 0.000417
-0.493497 0.474422 -0.728961 0.000501
-0.789287 -0.566719 0.236336 0.000413
0.293932 0.520691 -0.801551 0.000510
EOD
#
# Generate a heatmap on the surface of a sphere
#
set view equal xyz
set view 78, 246
set xyplane at 0
unset key
set xtics ("x" 0); set ytics ("y" 0); set ztics ("z" 1)
set hidden3d # only relevant to axis tics and labels
#
# Use spherical mapping to generate a set of points describing the surface.
# Then return to Cartesian coordinates to handle voxels.
#
set mapping spherical
set angle degrees
set samples 51
set isosamples 101
set urange [-90:90]
set vrange [0:360]
set table $surface
splot '++' using 1:2:(1.0) with points
unset table
set mapping cartesian
# define 100 x 100 x 100 voxel grid
rlow = -1.1; rhigh = 1.1
set xrange [rlow:rhigh]; set yrange [rlow:rhigh]; set zrange [rlow:rhigh]
set vgrid $vdensity size 100
vclear $vdensity
# mark voxels in a spherical region with radius <near> around each point in $data
# Note that values are summed rather than averaged
near = 0.1
vfill $data skip 1 using 1:2:3:(near):()
show vgrid
# color range should be found automatically but it isn't
set cbtics
set colorbox user origin screen 0.8, screen 0.2
set cbrange [ 0 : 0.001 ]
set palette cubehelix negative # colors from cbmin white -> cbmax dark
set pm3d depthorder
set pm3d lighting primary 0.4 specular 0.1
set title "Sphere surface is colored by the value of the nearest point[s] in $data"
splot $surface using 1:2:3:(voxel(,,)) with pm3d