我想在 gnuplot 中绘制它:
我的数据:
#x, y, cm[], r, theta, theta*180./M_PI
0.125 0.125 0.1309 0.125 0.1309 7.5
0.125 0.375 0.1309 0.125 0.392699 22.5
0.375 0.125 0.392699 0.375 0.1309 7.5
0.3125 0.3125 0.327249 0.3125 0.327249 18.75
0.3125 0.4375 0.327249 0.3125 0.458149 26.25
0.4375 0.3125 0.458149 0.4375 0.327249 18.75
0.4375 0.4375 0.458149 0.4375 0.458149 26.25
0.125 0.625 0.1309 0.125 0.654498 37.5
0.125 0.875 0.1309 0.125 0.916298 52.5
0.3125 0.5625 0.327249 0.3125 0.589049 33.75
0.3125 0.6875 0.327249 0.3125 0.719948 41.25
0.4375 0.5625 0.458149 0.4375 0.589049 33.75
0.4375 0.6875 0.458149 0.4375 0.719948 41.25
0.375 0.875 0.392699 0.375 0.916298 52.5
0.625 0.125 0.654498 0.625 0.1309 7.5
0.5625 0.3125 0.589049 0.5625 0.327249 18.75
0.5625 0.4375 0.589049 0.5625 0.458149 26.25
0.6875 0.3125 0.719948 0.6875 0.327249 18.75
0.6875 0.4375 0.719948 0.6875 0.458149 26.25
0.875 0.125 0.916298 0.875 0.1309 7.5
0.875 0.375 0.916298 0.875 0.392699 22.5
0.5625 0.5625 0.589049 0.5625 0.589049 33.75
0.5625 0.6875 0.589049 0.5625 0.719948 41.25
0.6875 0.5625 0.719948 0.6875 0.589049 33.75
0.6875 0.6875 0.719948 0.6875 0.719948 41.25
0.625 0.875 0.654498 0.625 0.916298 52.5
0.875 0.625 0.916298 0.875 0.654498 37.5
0.875 0.875 0.916298 0.875 0.916298 52.5
其中 cm[] 是我想在极坐标中绘制的值。 我想我需要使用 dgrid3d 但我不知道如何以及是否可以使用 gnuplot 获得相同的图像?
我的一段代码:
set pm3d map
unset key
set multiplot
# plot the heatmap
unset border
unset xtics
unset ytics
set angles degrees
r = 1
set xrange[-r:r]
set yrange[-r:r]
set colorbox user origin 0.9,0.1 size 0.03,0.8
#set dgrid3d 20,20
sp 'log' u 1:2:3
# now plot the polar grid only
set style line 11 lc rgb 'white' lw 2
set grid polar ls 11
set polar
set rrange[0:r]
unset raxis
set rtics format '' scale 0
set for [i=0:330:30] label at first (r+0.35)*cos(i), first (r+0.35)*sin(i)\
center sprintf('%d', i)
plot NaN w l
unset multiplot
我已经尝试过代码here:`
set mapping cylindrical
set view equal xy
set view map
set angle degrees
set dgrid3d 200,200
sp 'log' u 6:3:4 w pm3d
但这不是我想要的。在极坐标模式下,我无法使用 splot 和 pm3d。
我也尝试过这段代码:
set polar
set angles degrees
set grid polar 15. lt -1 dt 0 lw 0.5
unset border
unset xtics
unset ytics
unset raxis
p 'log' u 6:3
但我想用第 3 列设置的颜色填充网格
我已经简化了常规网格的数据:
#x, y, cm[], r, theta, theta*180./M_PI
0.125 0.125 0.1309 0.125 0.1309 7.5
0.125 0.375 0.1309 0.125 0.392699 22.5
0.375 0.125 0.392699 0.375 0.1309 7.5
0.375 0.375 0.392699 0.375 0.392699 22.5
0.125 0.625 0.1309 0.125 0.654498 37.5
0.125 0.875 0.1309 0.125 0.916298 52.5
0.375 0.625 0.392699 0.375 0.654498 37.5
0.375 0.875 0.392699 0.375 0.916298 52.5
0.625 0.125 0.654498 0.625 0.1309 7.5
0.625 0.375 0.654498 0.625 0.392699 22.5
0.875 0.125 0.916298 0.875 0.1309 7.5
0.875 0.375 0.916298 0.875 0.392699 22.5
0.625 0.625 0.654498 0.625 0.654498 37.5
0.625 0.875 0.654498 0.625 0.916298 52.5
0.875 0.625 0.916298 0.875 0.654498 37.5
0.875 0.875 0.916298 0.875 0.916298 52.5
通过此代码使用“简化”数据:
### workaround for polar heatmap
reset session
set table $Data
plot "log" using 6:4:3 with table
unset table
set size square
set angle degrees
unset border
unset tics
set cbtics
set polar
set border polar
unset raxis
set grid polar 15.
astep = 180./4
rstep = 0.25
# create the segments for each datapoint
set print $PolarHeatmap
do for [i=1:|$Data|] {
a = real(word($Data[i],1))
r = real(word($Data[i],2))
c = real(word($Data[i],3))
do for [j=0:5] {
print sprintf("%g %g %g",a+j*astep/10., r-0.5*rstep, c)
}
do for [j=5:0:-1] {
print sprintf("%g %g %g",a+j*astep/10., r+0.5*rstep, c)
}
print ""
print ""
}
set print
set style fill noborder
plot $PolarHeatmap u 1:2:3 w filledcurves palette notitle
### end of code
我几乎是我想要的,但我的数据是[0:Pi/3],但事实并非如此。 我不明白:[j=0:5] 和 [j=5:0:-1] 以及为什么我们需要再次打印。
这是一个令人惊讶的紧凑解决方案,但并不简单。这适用于您的情况,因为您的数据中有严格的网格。如果您没有常规网格,您可能需要使用
dgrid3d
进行插值(您已经尝试过)或 Delaunay-triangulation 或 Voronoi-diagram。
使用 gnuplot,您可以轻松绘制圆的线段。如果您按照正确的顺序进行操作,您可以获得所需的输出。基本思想是,您在半径和角度上有一个最小的常规步骤(此处:
dr=0.125
和da=7.5
),它们定义了最小单元格。如果您的数据点位于网格上,您可以将 4 个最小单元格合并为一个较大的单元格。
一些评论:
首先通过“严重误用”
smooth zsort
按半径递减的方式对数据进行排序,然后将其写入数据块$Sorted
。
检查您的数据点是否在网格上(
$1/dr==int($1/dr)
)。将其写入数据块的第3列$Grid
绘制
$Grid
时,如果数据点位于网格上,则采用当前半径 + dr
和当前角度 +/-da
来绘制圆段。如果数据点不在网格上,则分别取 +dr/2
和 +/-da/2
。
为了激活调色板(显然),您首先需要用数据的 zrange 绘制
(NaN):(NaN):3
(我还不知道为什么)。绘制圆段时它似乎不能立即工作。
您当然也可以在极坐标中做同样的事情。
数据:
SO77873892.dat
#x, y, cm[], r, theta, theta*180./M_PI
0.1250 0.1250 0.130900 0.1250 0.130900 7.50
0.1250 0.3750 0.130900 0.1250 0.392699 22.50
0.3750 0.1250 0.392699 0.3750 0.130900 7.50
0.3125 0.3125 0.327249 0.3125 0.327249 18.75
0.3125 0.4375 0.327249 0.3125 0.458149 26.25
0.4375 0.3125 0.458149 0.4375 0.327249 18.75
0.4375 0.4375 0.458149 0.4375 0.458149 26.25
0.1250 0.6250 0.130900 0.1250 0.654498 37.50
0.1250 0.8750 0.130900 0.1250 0.916298 52.50
0.3125 0.5625 0.327249 0.3125 0.589049 33.75
0.3125 0.6875 0.327249 0.3125 0.719948 41.25
0.4375 0.5625 0.458149 0.4375 0.589049 33.75
0.4375 0.6875 0.458149 0.4375 0.719948 41.25
0.3750 0.8750 0.392699 0.3750 0.916298 52.50
0.6250 0.1250 0.654498 0.6250 0.130900 7.50
0.5625 0.3125 0.589049 0.5625 0.327249 18.75
0.5625 0.4375 0.589049 0.5625 0.458149 26.25
0.6875 0.3125 0.719948 0.6875 0.327249 18.75
0.6875 0.4375 0.719948 0.6875 0.458149 26.25
0.8750 0.1250 0.916298 0.8750 0.130900 7.50
0.8750 0.3750 0.916298 0.8750 0.392699 22.50
0.5625 0.5625 0.589049 0.5625 0.589049 33.75
0.5625 0.6875 0.589049 0.5625 0.719948 41.25
0.6875 0.5625 0.719948 0.6875 0.589049 33.75
0.6875 0.6875 0.719948 0.6875 0.719948 41.25
0.6250 0.8750 0.654498 0.6250 0.916298 52.50
0.8750 0.6250 0.916298 0.8750 0.654498 37.50
0.8750 0.8750 0.916298 0.8750 0.916298 52.50
脚本:(需要 gnuplot>=5.4.0,因为
smooth zsort
)
### plot circle segments to mimic polar heatmap
reset session
FILE = "SO77873892.dat"
da = 7.5 # grid angle step
dr = 0.125 # grid radius step
set table $Sorted
plot FILE u 4:6:(-$4):3 smooth zsort lc var # sort by decreasing radius
set table $Grid
plot $Sorted u 1:2:3:($1/dr==int($1/dr)) w table # check if on the grid
unset table
set size ratio -1
set xrange[0:1]
set yrange[0:1]
set style fill transparent solid 1.0 border lc "black"
set key noautotitle
set palette defined (0 "#00d0ff", 1 "#40fffc", 2 "#b7ffc4", 3 "#f3ff65", 4 "#ffff00")
plot FILE u (NaN):(NaN):3 w p palette z, \
$Grid u (0):(0):(g=($4==1?1:0.5), $1+dr*g):($2-da*g):($2+da*g):3 w circles lc palette z
### end of script
结果: