第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

gnuplot“條件”:三列上的倍數(shù)曲線(30?)

gnuplot“條件”:三列上的倍數(shù)曲線(30?)

慕容3067478 2023-03-16 09:56:18
我這輩子寫的腳本很少,但我?guī)缀踔粚?bash。從來不需要更多。到現(xiàn)在為止:我想用包裝器制作一些圖表,這些1 type1 12 type1 23 type2 14 type1 35 type2 26 type3 1模式在哪里:第一列:排名 {1..10000}第二列:類別(已知)第 3 列:正在計算從一開始它看到類別數(shù)據的次數(shù)占總數(shù)的百分比(范圍 0 到 1)(我沒有英文單詞?也許cumulate sum?在電子表格中,第 3 列類似于=(NB.si($B$1:$B4;$B4)/nb.si($B$1:$B;$B4)第 4 行。我仍在處理如何在 python 中將“累積”總和附加到數(shù)據中(我當時只有第一列的兩列),這是簡單的數(shù)學和文本處理腳本。我知道如何在電子表格中實現(xiàn)自動化,在 bash 中有一些想法,但我對 python 知之甚少。但是,這不是我的問題(但我在這里向仁慈的人開放:))問題我發(fā)現(xiàn)gnuplot可能有幫助,我閱讀了各種網站上的手冊和一些示例,但我仍然有點困惑:我將如何繪制樹曲線,從 0 開始,到 1,用X 斧頭:第 1 列Y 軸:第 3 列曲線:{type1, type2, type3}
查看完整描述

1 回答

?
繁星淼淼

TA貢獻1775條經驗 獲得超11個贊

我會做這樣的事情


# 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?$3:NaN) w l ls f(i)

得到這個

http://img1.sycdn.imooc.com//6412777200013aad06370477.jpg

如果需要,您可以for從 plot 命令中刪除并僅使用plot 'test.dat' u (strcol(2) eq "type1"?$3:NaN) w l ls 1, 'test.dat' u (strcol(2) eq "type2"?$3:NaN) w l ls 2, 為每種類型顯式繪圖,并更好地控制每條繪圖線的細節(jié)。

您可以制作另一個函數(shù)來為每一行添加標題,類似于f(x)但返回每種類型的字符串而不是 int。

我還聽說過使用 awk 或內部函數(shù)在 gnuplot 中進行累積和的方法,您可以在此處查看gnuplot-cumulative-column-question


查看完整回答
反對 回復 2023-03-16
  • 1 回答
  • 0 關注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號