Loops gnuplot拟合并重写循环内部的绘图
我对gnuplot有意见。我确实需要适应两个数据文件(比如file1和file2),它们有51列。我是这样做的Loops gnuplot拟合并重写循环内部的绘图,loops,for-loop,gnuplot,data-fitting,Loops,For Loop,Gnuplot,Data Fitting,我对gnuplot有意见。我确实需要适应两个数据文件(比如file1和file2),它们有51列。我是这样做的 do for [j=2:51] { fxj(x) = Dxj*x+ qxj fit [xmin:xmax] fxj(x) '< paste file1 file2' u 1:(((column(j))+(column(j+51)))/2) via Dxj, qxj print
do for [j=2:51] {
fxj(x) = Dxj*x+ qxj
fit [xmin:xmax] fxj(x) '< paste file1 file2' u 1:(((column(j))+(column(j+51)))/2) via Dxj, qxj
print j, ' ', Dxj/2
}
do for [j=2:51] {
fxj(x) = Dxj*x+ qxj
fit [xmin:xmax] fxj(x) '< paste file1 file2' u 1:(((column(j))+(column(j+51)))/2) via Dxj, qxj
print j, ' ', Dxj/2
plot '< paste file1 file2' u 1:(((column(j))+(column(j+51)))/2) t'', fxj(x) t''
}
但它不起作用。
您有什么建议可以让它工作吗?一种方法可以是使用
多点
,如下面的简化示例所示。其想法是固定绘图边距,以便多点环境中的每个连续绘图在同一“区域”上绘图。此外,在循环内部,脚本确保除第一个情节外的所有情节都会取消tics等的设置,以便它们不会被绘制多次
set multiplot
set lmargin at screen 0.1
set rmargin at screen 0.9
set bmargin at screen 0.1
set tmargin at screen 0.9
set xr [-2:2]
set yr [-4:4]
do for [j=1:3]{
if(j>1){
unset xtics;
unset ytics;
unset border;
unset xlabel;
unset ylabel;
}
set key at screen 0.3,0.9 - j*0.05 reverse
plot j*x w l t sprintf('plot %d', j);
}
这将产生:
或者,您可以先运行do
循环,在数组中组合系数,然后立即绘制所有内容:
set xr [-2:2]
set yr [-4:4]
array coeffs_a[3]
array coeffs_b[3]
do for [j=1:3]{
#save the fitted coefficients
coeffs_a[j] = j
coeffs_b[j] = j
}
plot for [j=1:3] coeffs_a[j]*x + coeffs_b[j] w l t sprintf('plot %d', j)
欢迎来到SO。你能在问题中添加哪些代码不起作用吗?这使得找到问题和回答问题变得更加容易。我最喜欢的:三条相同的紫色线条的传说。@mikuszefski啊,真是太遗憾了!:)嗯,我只是想展示如何在重叠情节场景中定位图例。。。