我正在尝试在Gnuplot中绘制热图:
set view map
set size square
set cbrange [0:1]
splot "input.dat" 1:4:8 w pm3d
Run Code Online (Sandbox Code Playgroud)
但是我想跳过第一和第四列中特定范围内的数据的行,而不更改xrange和yrange。我怎样才能做到这一点?
如果要跳过xmin和之间的x值xmax,以及之间的y值ymin,则ymax可以进行条件绘图:
splot "input.dat" u 1:4:( $1 >= xmin && $1 <= xmax && \
$4 >= ymin && $4 <= ymax ? 1/0 : $8 ) w pm3d
Run Code Online (Sandbox Code Playgroud)
上面的代码告诉gnuplot忽略范围之外的点。
例如,我使用生成以下随机数据bash:
for i in `seq 1 1 100`
do for j in `seq 1 1 100`
do echo $i $j $RANDOM >> input.dat
done
echo "" >> input.dat
done
Run Code Online (Sandbox Code Playgroud)
现在告诉gnuplot忽略某个区域:
xmin = 25; xmax = 36; ymin = 67; ymax = 88
set view map
splot "input.dat" u 1:2:( $1 >= xmin && $1 <= xmax && \
$2 >= ymin && $2 <= ymax ? 1/0 : $3 ) w pm3d not
Run Code Online (Sandbox Code Playgroud)

如果要跳过多个区域,只需使用“或”逻辑运算符||来分隔区域:
xmin1 = 25; xmax1 = 36; ymin1 = 67; ymax1 = 88
xmin2 = 50; xmax2 = 90; ymin2 = 23; ymax2 = 34
set view map
splot "input.dat" u 1:2:( \
($1 >= xmin1 && $1 <= xmax1 && $2 >= ymin1 && $2 <= ymax1) \
|| \
($1 >= xmin2 && $1 <= xmax2 && $2 >= ymin2 && $2 <= ymax2) \
? 1/0 : $3 ) w pm3d not
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
976 次 |
| 最近记录: |