Invert/reverse 累计 gnuplot
Invert/reverse cumulative gnuplot
我可以使用此输入文件制作累积图:
set key top left
set xtics font 'Arial,18'
set terminal pdf solid font 'Arial,18' # pdf files are great for inkscape
set output 'cumulative.pdf'
unset xtics; unset ytics # Remove all tics
set ytics nomirror # Only have tics on left
set xtics nomirror # Only have tics on bottom
set border 3 # Only have border on bottom and left
set xrange [50:170]
#set yrange [0:10000]
set xtics 50,10,170
#set ytics 0,20,100
set tics out nomirror
plot "1.3SLN-all.txt" using 1:(.0000401) smooth cumul title "1.3SLN", \
"1.6SLN-all.txt" using 1:(.0000401) smooth cumul title "1.6SLN", \
"2.3SDLN-all.txt" using 1:(.0000401) smooth cumul title "2.3SDLN", \
"2.6SDLN-all.txt" using 1:(.0000401) smooth cumul title "2.6SDLN", \
"3.3STLN-all.txt" using 1:(.0000401) smooth cumul title "3.3STLN", \
"3.6STLN-all.txt" using 1:(.0000401) smooth cumul title "3.6STLN"
这会产生这个情节:
数据文件如下所示:
52.712
52.246
52.391
53.814
52.260
57.365
58.331
53.628
55.391
55.422
等等
我想要的是反转它,以便它从最大数到最小数累加。所以像这样:
这是我编辑的。我想把我所有的数字都设为负数,然后再编辑轴,但这不是很令人满意。
假设我正确理解了你的问题。
尝试以下示例并根据您的需要进行调整:
- 使用
smooth frequency
将文件绘制成数据块。检查 help smooth frequency
.
- 反转数据块
- 累计数据块"manually"
可能有一种方法可以不将反向和累积的数据写入文件,使用更多的数据块或数组。
代码:
### reverse cumulative plot
reset session
FILES = 'One Two Three Four Five Six'
FileCount = words(FILES)
File(i) = sprintf("%s-all.txt",word(FILES,i))
# create some random test data
do for [i=1:FileCount] {
set samples int(rand(0)*500)+100
set table File(i)
offset = rand(0)*5+4
plot '+' u (invnorm(rand(0))+offset) w table
unset table
}
# smooth, reverse, cumulate data
do for [i=1:FileCount] {
# smooth file data into datablock
set table $Data
plot [][0:1] File(i) u 1:(4.01e-5) smooth frequency
unset table
# reverse the datablock
set print $DataR
do for [j=|$Data|:1:-1] {
print $Data[j]
}
set print
# cumulate the reversed datablock into file
set table File(i)."_RC.dat"
plot c=0 $DataR u 1:(c=c+) w table
unset table
}
set yrange[-0.002:]
set multiplot layout 2,1
set title "cumulative"
set key top left
plot for [i=1:FileCount] File(i) u 1:(4.01e-5) smooth cumulative w l lw 2 ti File(i) noenhanced
set title "reverse cumulative"
set key top right
plot for [i=1:FileCount] File(i)."_RC.dat" u 1:2 w l ti File(i) lw 2 noenhanced
unset multiplot
### end of code
结果:
我可以使用此输入文件制作累积图:
set key top left
set xtics font 'Arial,18'
set terminal pdf solid font 'Arial,18' # pdf files are great for inkscape
set output 'cumulative.pdf'
unset xtics; unset ytics # Remove all tics
set ytics nomirror # Only have tics on left
set xtics nomirror # Only have tics on bottom
set border 3 # Only have border on bottom and left
set xrange [50:170]
#set yrange [0:10000]
set xtics 50,10,170
#set ytics 0,20,100
set tics out nomirror
plot "1.3SLN-all.txt" using 1:(.0000401) smooth cumul title "1.3SLN", \
"1.6SLN-all.txt" using 1:(.0000401) smooth cumul title "1.6SLN", \
"2.3SDLN-all.txt" using 1:(.0000401) smooth cumul title "2.3SDLN", \
"2.6SDLN-all.txt" using 1:(.0000401) smooth cumul title "2.6SDLN", \
"3.3STLN-all.txt" using 1:(.0000401) smooth cumul title "3.3STLN", \
"3.6STLN-all.txt" using 1:(.0000401) smooth cumul title "3.6STLN"
这会产生这个情节:
数据文件如下所示:
52.712
52.246
52.391
53.814
52.260
57.365
58.331
53.628
55.391
55.422
等等
我想要的是反转它,以便它从最大数到最小数累加。所以像这样:
这是我编辑的。我想把我所有的数字都设为负数,然后再编辑轴,但这不是很令人满意。
假设我正确理解了你的问题。 尝试以下示例并根据您的需要进行调整:
- 使用
smooth frequency
将文件绘制成数据块。检查help smooth frequency
. - 反转数据块
- 累计数据块"manually"
可能有一种方法可以不将反向和累积的数据写入文件,使用更多的数据块或数组。
代码:
### reverse cumulative plot
reset session
FILES = 'One Two Three Four Five Six'
FileCount = words(FILES)
File(i) = sprintf("%s-all.txt",word(FILES,i))
# create some random test data
do for [i=1:FileCount] {
set samples int(rand(0)*500)+100
set table File(i)
offset = rand(0)*5+4
plot '+' u (invnorm(rand(0))+offset) w table
unset table
}
# smooth, reverse, cumulate data
do for [i=1:FileCount] {
# smooth file data into datablock
set table $Data
plot [][0:1] File(i) u 1:(4.01e-5) smooth frequency
unset table
# reverse the datablock
set print $DataR
do for [j=|$Data|:1:-1] {
print $Data[j]
}
set print
# cumulate the reversed datablock into file
set table File(i)."_RC.dat"
plot c=0 $DataR u 1:(c=c+) w table
unset table
}
set yrange[-0.002:]
set multiplot layout 2,1
set title "cumulative"
set key top left
plot for [i=1:FileCount] File(i) u 1:(4.01e-5) smooth cumulative w l lw 2 ti File(i) noenhanced
set title "reverse cumulative"
set key top right
plot for [i=1:FileCount] File(i)."_RC.dat" u 1:2 w l ti File(i) lw 2 noenhanced
unset multiplot
### end of code
结果: