gnuplot "condition":三列上的倍数曲线(30?)
gnuplot "condition" : multiples curves (30 ?) on three columns
我一生写的剧本很少,但我几乎只写过bash。从来不需要更多。到现在为止:我想用包装器制作一些图表,这些
1 type1 1
2 type1 2
3 type2 1
4 type1 3
5 type2 2
6 type3 1
模式在哪里:
- 第 1 列:排名 {1..10000}
- 第 2 列:类别(已知)
- 第 3 列:正在计算从一开始它看到类别数据的次数占总数的百分比(范围 0 到 1)(我没有英文单词?
cumulate sum
也许?
在电子表格中,第 4 行的 3d 列类似于 =(NB.si($B:$B4;$B4)/nb.si($B:$B;$B4)
。
我仍在处理我将如何在 python 中追加数据中的“累积”总和(当时我只有第一列的两列),这是简单的数学和文本处理脚本.我知道如何在电子表格中实现自动化,在 bash 中有一些想法,但我对 python 知之甚少。但是,这不是我的问题(但我在这里向仁慈的人开放:))
问题
我发现 gnuplot
可能有帮助,我阅读了各种网站上的手册和一些示例,但我仍然有点困惑:我如何绘制树曲线,从 0 开始,到 1,与
- X 斧头:第 1 列
- Y 轴:第 3 列
- 曲线:{type1, type2, type3}
谢谢你们! :)
我会做这样的事情
# this function relates every type to an int, convenient for setting the plot styles
f(x) = x eq "type1"? 1: x eq "type2"? 2:0
# this tell gnuplot to ignore the result of lines not matching
set datafile missing "NaN"
# setting a nice style for every type
set style line 1 linetype 1 linewidth 2 pointtype 3 linecolor rgb "red"
set style line 2 linetype 1 linewidth 2 pointtype 3 linecolor rgb "blue"
# using a ternary operator to pick out the lines matching that type
plot for [i in "type1 type2"] 'test.dat' u (strcol(2) eq i?:NaN) w l ls f(i)
如果需要,您可以从绘图命令中删除 for
并仅使用 plot 'test.dat' u (strcol(2) eq "type1"?:NaN) w l ls 1, 'test.dat' u (strcol(2) eq "type2"?:NaN) w l ls 2
,为每种类型显式绘图,并更好地控制每条绘图线的细节。
您可以创建另一个函数来为每一行添加标题,类似于 f(x)
但返回每种类型的字符串而不是 int。
我也听说过用 awk 或内部函数在 gnuplot 中求和的方法,你可以在这里查看 gnuplot-cumulative-column-question
我一生写的剧本很少,但我几乎只写过bash。从来不需要更多。到现在为止:我想用包装器制作一些图表,这些
1 type1 1
2 type1 2
3 type2 1
4 type1 3
5 type2 2
6 type3 1
模式在哪里:
- 第 1 列:排名 {1..10000}
- 第 2 列:类别(已知)
- 第 3 列:正在计算从一开始它看到类别数据的次数占总数的百分比(范围 0 到 1)(我没有英文单词?
cumulate sum
也许?
在电子表格中,第 4 行的 3d 列类似于 =(NB.si($B:$B4;$B4)/nb.si($B:$B;$B4)
。
我仍在处理我将如何在 python 中追加数据中的“累积”总和(当时我只有第一列的两列),这是简单的数学和文本处理脚本.我知道如何在电子表格中实现自动化,在 bash 中有一些想法,但我对 python 知之甚少。但是,这不是我的问题(但我在这里向仁慈的人开放:))
问题
我发现 gnuplot
可能有帮助,我阅读了各种网站上的手册和一些示例,但我仍然有点困惑:我如何绘制树曲线,从 0 开始,到 1,与
- X 斧头:第 1 列
- Y 轴:第 3 列
- 曲线:{type1, type2, type3}
谢谢你们! :)
我会做这样的事情
# this function relates every type to an int, convenient for setting the plot styles
f(x) = x eq "type1"? 1: x eq "type2"? 2:0
# this tell gnuplot to ignore the result of lines not matching
set datafile missing "NaN"
# setting a nice style for every type
set style line 1 linetype 1 linewidth 2 pointtype 3 linecolor rgb "red"
set style line 2 linetype 1 linewidth 2 pointtype 3 linecolor rgb "blue"
# using a ternary operator to pick out the lines matching that type
plot for [i in "type1 type2"] 'test.dat' u (strcol(2) eq i?:NaN) w l ls f(i)
如果需要,您可以从绘图命令中删除 for
并仅使用 plot 'test.dat' u (strcol(2) eq "type1"?:NaN) w l ls 1, 'test.dat' u (strcol(2) eq "type2"?:NaN) w l ls 2
,为每种类型显式绘图,并更好地控制每条绘图线的细节。
您可以创建另一个函数来为每一行添加标题,类似于 f(x)
但返回每种类型的字符串而不是 int。
我也听说过用 awk 或内部函数在 gnuplot 中求和的方法,你可以在这里查看 gnuplot-cumulative-column-question