具有多个数据集的 gnuplot 绘图
gnuplot splot with multiple data sets
我有一个生成 gnuplot 文件的脚本,我进行了编辑,因此我在同一个图中有 2 组数据。一个乘以 -1 来改变颜色。然而,情节中只出现了一组,即最后一组。脚本如下。
set arrow from graph 0,first 0.61237, graph 0 to graph1,first0.61237,0 nohead front lt -1
set arrow from graph 0,first 1.67303, graph 0 to graph 1,first 1.67303,0 nohead front lt -1
set arrow from graph 0,first 2.53906, graph 0 to graph 1,first 2.53906,0 nohead front lt -1
set arrow from graph 0,first 3.24616, graph 0 to graph 1,first 3.24616,0 nohead front lt -1
set arrow from graph 0,first 3.74616, graph 0 to graph 1,first 3.74616,0 nohead front lt -1
set arrow from graph 0,first 4.74616, graph 0 to graph 1,first 4.74616,0 nohead front lt -1
set pm3d at b
unset surf
set view 180,90
set palette defined (-1 "red",0 "white", 1 "blue");
set grid xtics mxtics ytics
unset border
set xrange [-10:40]
set xtics -10,((40+10)/5),40
set mxtics 3
set yzeroax lt 2
set ytics ("L" 0.0,"K" 0.61237,"G" 1.67303,"L" 2.53906,"W" 3.24616,"X" 3.74616,"G" 4.74616)
set cbrange resto
set cbrange[-1:1]
set colorbox
set terminal png enhanced nocrop size 1920,1080
set out "SPF_NO_SO.png"
splot "specfun.pm3d" u (*13.60569806):2:(1*/476.70750366666666666666),\
"specfun.pm3d" u (*13.60569806):2:(1*/573.04673900000000000000)
unset out
示例图片:
该脚本仅为负集生成所需的图。如果我翻转订单,我会得到蓝色的。
这是一个示例数据:
data_sample
仅供参考 - 这些数组非常大
正如@user8153 所指出的,我也没有看到使用 splot
的原因。
正如@Christoph 指出的那样,不知道数据的样子是很困难的,
例如,</code> 和 <code>
列中的内容是什么?
顺便说一句,使用你的 plot 命令 ...u (*13.60569806):2
是不是你在彼此之上两次绘制相同的函数,也就是说,这就是你看到红色或蓝色的原因?
不过,我试图预测您可能想要做什么。我缩放了第二个函数并假设列 </code> 和 <code>
是线性的。请澄清。
使用代码:
### start code
reset session
# generate some dummy data
undefine $Data
set print $Data append
do for [n=1:5] {
a = rand(0)*10
b = rand(0)*0.1+0.1
c = rand(0)*20
do for [i=1:100] {
print sprintf("%g\t%g\t%g\t%g",i,(a*sin(b*i-c)),cos(b*i),cos(b*3*i))
}
print "" # insert empty line for data curve separation
}
set print
# print $Data
# end generating dummy data
set palette defined (-1 "red",0 "white", 1 "blue")
set cbrange [-1:1]
plot $Data u 1:2:(-) w l lc palette z
### end of code
您将获得以下内容:
我有一个生成 gnuplot 文件的脚本,我进行了编辑,因此我在同一个图中有 2 组数据。一个乘以 -1 来改变颜色。然而,情节中只出现了一组,即最后一组。脚本如下。
set arrow from graph 0,first 0.61237, graph 0 to graph1,first0.61237,0 nohead front lt -1
set arrow from graph 0,first 1.67303, graph 0 to graph 1,first 1.67303,0 nohead front lt -1
set arrow from graph 0,first 2.53906, graph 0 to graph 1,first 2.53906,0 nohead front lt -1
set arrow from graph 0,first 3.24616, graph 0 to graph 1,first 3.24616,0 nohead front lt -1
set arrow from graph 0,first 3.74616, graph 0 to graph 1,first 3.74616,0 nohead front lt -1
set arrow from graph 0,first 4.74616, graph 0 to graph 1,first 4.74616,0 nohead front lt -1
set pm3d at b
unset surf
set view 180,90
set palette defined (-1 "red",0 "white", 1 "blue");
set grid xtics mxtics ytics
unset border
set xrange [-10:40]
set xtics -10,((40+10)/5),40
set mxtics 3
set yzeroax lt 2
set ytics ("L" 0.0,"K" 0.61237,"G" 1.67303,"L" 2.53906,"W" 3.24616,"X" 3.74616,"G" 4.74616)
set cbrange resto
set cbrange[-1:1]
set colorbox
set terminal png enhanced nocrop size 1920,1080
set out "SPF_NO_SO.png"
splot "specfun.pm3d" u (*13.60569806):2:(1*/476.70750366666666666666),\
"specfun.pm3d" u (*13.60569806):2:(1*/573.04673900000000000000)
unset out
示例图片:
该脚本仅为负集生成所需的图。如果我翻转订单,我会得到蓝色的。
这是一个示例数据: data_sample 仅供参考 - 这些数组非常大
正如@user8153 所指出的,我也没有看到使用 splot
的原因。
正如@Christoph 指出的那样,不知道数据的样子是很困难的,
例如,</code> 和 <code>
列中的内容是什么?
顺便说一句,使用你的 plot 命令 ...u (*13.60569806):2
是不是你在彼此之上两次绘制相同的函数,也就是说,这就是你看到红色或蓝色的原因?
不过,我试图预测您可能想要做什么。我缩放了第二个函数并假设列 </code> 和 <code>
是线性的。请澄清。
使用代码:
### start code
reset session
# generate some dummy data
undefine $Data
set print $Data append
do for [n=1:5] {
a = rand(0)*10
b = rand(0)*0.1+0.1
c = rand(0)*20
do for [i=1:100] {
print sprintf("%g\t%g\t%g\t%g",i,(a*sin(b*i-c)),cos(b*i),cos(b*3*i))
}
print "" # insert empty line for data curve separation
}
set print
# print $Data
# end generating dummy data
set palette defined (-1 "red",0 "white", 1 "blue")
set cbrange [-1:1]
plot $Data u 1:2:(-) w l lc palette z
### end of code
您将获得以下内容: