gnuplot:来自同一 splot 中两个不同文件的轮廓和热图

标签 gnuplot

我正在尝试使用以下代码绘制两个二维标量,一个作为热图,一个作为叠加轮廓:

set contour base
set cntrparam levels incremental 0,0.25,1.25
unset surface
set table cont2.dat
splot 'vr245.gnu'
unset table
reset
set xrange [1:215]
set yrange [0:3.1415925025940E+00]
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10
splot 'f_aveFe_245.gnu' u 1:2:3 with pm3d, "cont2.dat" u 1:2:3 w l

gnuplot 产生的结果
Result produced by gnuplot

如您所见,轮廓左侧有伪影。我该如何解决这个问题?谢谢!

Input files are here.

最佳答案

这实际上很有趣。问题似乎出现在对应于 1.25 级别的特定轮廓上。 .我想我将问题隔离到以下几点。

让我们假设我们有一个简单的数据文件

215  2.55865  1.25 
212.185  2.56004  1.25 
215  2.87839  1.25 

215  0.2632  1.25 
212.185  0.252052  1.25 
215  0.582938  1.25

现在,gnuplot 命令
unset key
set view map

set xr [212:215.5]
set yr [0:3]

set xtics nomirror
set ytics nomirror

splot \
    'file.dat' w lp, \
    '' u 1:2:3:(sprintf("%d", $0)) w labels offset char 0, char -0.5

生产
enter image description here

有趣的是,第 1 点和第 4 点也连接在一起。如果将数据文件修改为
215  2.55865  1.25 
212.185  2.56004  1.25 
215  2.87839  1.25 
#
215  0.2632  1.25 
212.185  0.252052  1.25 
215  0.582938  1.25

Gnuplot 仅按预期连接第 2 点和第 3 点:
enter image description here

这里似乎有帮助的是复制空行,即这个文件
215  2.55865  1.25 
212.185  2.56004  1.25 
215  2.87839  1.25 


215  0.2632  1.25 
212.185  0.252052  1.25 
215  0.582938  1.25

给出确实断开连接的组件:
enter image description here

要将其应用到您的脚本中,您可以调用例如 gawk并仅使用计算出的轮廓复制文件中的所有空白行:
set terminal pngcairo
set output 'fig.png'

set contour base
set cntrparam levels incremental 0,0.25,1.25
unset surface
set table 'cont2.dat'
splot 'vr245.gnu'
unset table
reset

set xrange [1:215]
set yrange [0:pi]
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10
splot \
    'f_aveFe_245.gnu' u 1:2:3 with pm3d, \
    '<gawk "NF==0{print;} {print;}" cont2.dat' u 1:2:3 w l

这使
enter image description here

或者,您可以使用 plot 解决此问题。绘制轮廓而不是 splot :
set terminal pngcairo
set output 'fig.png'

set contour base
set cntrparam levels incremental 0,0.25,1.25
unset surface
set table 'cont2.dat'
splot 'vr245.gnu'
unset table
reset

set xrange [1:215]
set yrange [0:pi]
set cbrange [7:17]
unset key
set view map
set palette rgbformulae 33,13,10

set multiplot

set tmargin at screen 0.9
set lmargin at screen 0.1
set rmargin at screen 0.8
set bmargin at screen 0.1

splot \
    'f_aveFe_245.gnu' u 1:2:3 with pm3d

unset xtics
unset ytics
unset border
unset key
plot \
    'cont2.dat' w l

关于gnuplot:来自同一 splot 中两个不同文件的轮廓和热图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44055951/

相关文章:

gnuplot - 如何在 Gnuplot 中使用非线性轴?

重复绘图命令,在 R 中进行细微更改

gnuplot - 秤测量数据

plot - Gnuplot:网格后面多图中的第二个图例

Gnuplot:显示包含 z 值的鼠标悬停工具提示

gnuplot - 在 Gnuplot 中绘制具有不同点样式的曲线

曲线之间的 Gnuplot 透明阴影区域

c - 需要帮助通过 C 管道使用 gnuplot 绘制最简单的 x,y 图

gnuplot - 如何在 Gnuplot 中运行 shell 命令并将输出放入新文件中

gnuplot - gnuplot图例中的粗线