绘制热图时如何跳过Gnuplot中的行? [英] How do I skip rows in Gnuplot when plotting a heat map?
问题描述
我正在尝试在Gnuplot中绘制热图:
I'm trying to plot a heat map in Gnuplot:
set view map
set size square
set cbrange [0:1]
splot "input.dat" 1:4:8 w pm3d
但是我想跳过第一个&中包含数据的行.在不更改xrange
和yrange
的情况下在特定范围内的第四列.我该怎么办?
But I want to skip the rows with the data in the first & fourth column in a particular range without changing xrange
and yrange
. How can I do that?
推荐答案
如果要跳过xmin
和xmax
之间的x值,以及ymin
和ymax
之间的y值,则可以进行条件绘图:
If you want to skip x values between xmin
and xmax
, and y values between ymin
and ymax
you can do a conditional plot:
splot "input.dat" u 1:4:( $1 >= xmin && $1 <= xmax && \
$4 >= ymin && $4 <= ymax ? 1/0 : $8 ) w pm3d
上面的代码告诉gnuplot忽略范围之外的点.
The code above tells gnuplot to ignore the points outside of range.
例如,我使用bash
生成以下随机数据:
For instance, I generate the following random data with 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
现在告诉gnuplot忽略某个区域:
And now tell gnuplot to ignore a certain region:
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
如果要跳过多个区域,只需使用或"逻辑运算符||
来划定区域:
If you have multiple regions that you want to skip simply use an "or" logical operator ||
to delimit areas:
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
这篇关于绘制热图时如何跳过Gnuplot中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!