我有一个只包含数值的.csv文件。我想将每一行绘制为单独的绘图,并使用y轴上的值与值作为x值的位置。 即:
10,2,5,6
9,7,8,6
如果没有外部重新排列数据,是否可以这样做?
答案 0 :(得分:0)
从我所看到的,gnuplot逐列绘制文件。所以你可能需要重新排列数据。 您可以查看此主题: how plot per rows in gnuplot
答案 1 :(得分:0)
这是一组非常模糊的命令,可以满足您的要求。我毫不犹豫地推荐它,因为它在被混淆时是不明显的,并且对于空字段或缺少数据而言它是脆弱的。需要gnuplot第5版。
# Specify that this is a *.csv file
set datafile separator ","
# This command will plot value as a function of column for row n
plot 'rowdata' matrix using 1:0 every :::n::n with lp
# This command will do the same for each row in the file
plot for [col=1:*] 'rowdata' matrix using 1:0 every :::col::col with lp
答案 2 :(得分:0)
对于那些感兴趣的人,这是我最终得到的两个脚本:
使用gnuplot(在开头和结尾停止)动画系列图:
unset key
set datafile separator ","
stats "radii.csv" every ::1::1 using (time = $203) name "R" nooutput
set title sprintf("Time = %d",time)
stats "measureUnbound.csv" matrix every :::0:201:0 name "mU" nooutput
ubMin = 1.*mU_max
set yrange [0:40]
pl "radii.csv" matrix u 1:0 every :::1:201:1 w l \
,"radii.csv" matrix u 1:0 every :::0:201:0 w l \
,"measureUnbound.csv" matrix u 1:($3/ubMin*19.5) every :::0:201:0 w i
pause -1
do for [col=1:19000] { \
unset yrange
stats "radii.csv" every ::(col + 1)::(col + 1) using (time = $203) name "R" nooutput
set title sprintf("Time = %d",time)
stats "measureUnbound.csv" matrix every :::col:201:col name "mU" nooutput
ubMin = 1.*mU_max
set yrange [0:40]
pl "radii.csv" matrix u 1:0 every :::(col + 1):201:(col + 1) w l \
,"radii.csv" matrix u 1:0 every :::0:201:0 w l \
,"measureUnbound.csv" matrix u 1:($3/ubMin*19.5) every :::col:201:col w i
pause 0.1
}
pause -1
制作动画gif:
set term gif animate
set output "radii.gif"
unset key
set datafile separator ","
do for [col=0:19000] { \
unset yrange
stats "radii.csv" every ::(col + 1)::(col + 1) using (time = $203) name "R" nooutput
set title sprintf("Time = %d",time)
stats "measureUnbound.csv" matrix every :::col:201:col name "mU" nooutput
ubMin = 1.*mU_max
set yrange [0:40]
pl "radii.csv" matrix u 1:0 every :::(col + 1):201:(col + 1) w l \
,"radii.csv" matrix u 1:0 every :::0:201:0 w l \
,"measureUnbound.csv" matrix u 1:($3/ubMin*19.5) every :::col:201:col w i
}
set output
感谢您的帮助!