2016-07-06 45 views
0

我在使用代码时遇到以下错误。绘图命令中awk的gnuplot错误

gnuplot> set terminal epslatex size 13.1cm,6cm color colortext 
Terminal type set to 'epslatex' 
Options are ' leveldefault color colortext \ 
    dashed dashlength 1.0 linewidth 1.0 butt noclip \ 
    nobackground \ 
    palfuncparam 2000,0.003 \ 
    input size 13.10cm, 6.00cm "" 11 fontscale 1.0 ' 
gnuplot> set output 'C:\MajCha\gnuplot\alpha_cl.tex' 
gnuplot> filename= 'C:\MajCha\gnuplot\DU_08-W-180-65_cf_c_02_InpPrePro.txt' 
gnuplot> # 
gnuplot> set xrange [-10:10] 
gnuplot> set yrange [-3:3] 
gnuplot> plot "< awk '$1==-180.0 { print $2, $3 }'" filename using 2:3 
     warning: Skipping unreadable file "< awk '$1==-180.0 { print $2, $3 }'" 
     No data in plot 

gnuplot> # 
gnuplot> unset output 
gnuplot> reset 

我怎么能解决这个error.I想我在一个循环范围作出§1= -180 -180至180支票,请给我建议一些可能的方法可以做到。

随着使用以下代码

reset 
set terminal epslatex size 13.1cm,6cm color colortext 
set output 'C:\MajCha\gnuplot\alpha_cl.tex' 
filename= 'C:\MajCha\gnuplot\DU_08-W-180-65_cf_c_02_InpPrePro.txt' 
# 
unset key 
set xrange [-10:10] 
set yrange [-3:3] 
plot for [i=-180:180] filename using (($1==i)?$2:1/0):3 
# 
unset output 
reset 

输出数字是 enter image description here 随着使用以下代码

reset 
set terminal epslatex size 13.1cm,6cm color colortext 
set output 'C:\MajCha\gnuplot\alpha_cl.tex' 
filename= 'C:\MajCha\gnuplot\DU_08-W-180-65_cf_c_02_InpPrePro.txt' 
# 
unset key 
set xrange [-10:10] 
set yrange [-3:3] 
plot for [i=-180:180] filename using (($1==i)?$2:1/0):3 with lines 
# 
unset output 
reset 

输出数字是 enter image description here

+1

您需要的语法如下:'阴谋“

+0

如果您可以显示一段数据,并具体说明想要获得的结果,这将有所帮助。 –

+1

'awk'是一个命令行工具,它不是gnuplot的一部分,并且您的Windows系统上可能没有这个工具 – Christoph

回答

1

由于filename是gnuplot的你的MWE变量,哟ü可以做的是串联其内容awk命令:

plot "<awk '$1==-180.0 { print $2, $3 }' ".filename using 1:2 

不要错过闭幕"前的空格字符:这将评估命令

awk '$1==-180.0 { print $2, $3 }' C:\MajCha\gnuplot\DU_08-W-180-65_cf_c_02_InpPrePro.txt 

这是我相信你想做。目前,它正在评估没有文件的awk,因此没有数据。

注意,因为你的awk命令只打印$2$3,其输出由2列的,所以你可能想在gnuplot的using 1:2

最后,如果这MWE接近你真正想实现,我会建议放弃AWK和使用只为简单的gnuplot命令:

plot filename using (($1==-180)?$2:1/0):3 
+0

我已经使用了下面的命令,它只是绘制标题,但没有图 使用(($ 1 == i)?$ 2:1/0)绘制[i = -180:180]文件名:3使用行 –

+1

这样你就会有361个图表,所有整数i都在[-180,180]除非你使用'unset key',否则你什么也看不到。然后,您应该发布一些数据,以了解问题仍然存在的原因。 – Joce

+0

我已编辑我的问题请看看 –