天天看點

gnuplot使用備忘

gnuplot使用備忘

在 gnuplot 下畫圖,輸入如下指令,将圖檔儲存為.eps 矢量圖格式

set xlable ”frequency”  
set ylable "amplitude"  
set term jpeg 
set out "FFTsinesignaldata.jpg" 
filename = 'FFTsinesignaldata.txt' #載入資料檔案 
plot "result.txt" w l 
# 設定輸出為eps 
set term post eps 
set out "FFTsinesignaldata.eps" 
replot
           

舉一個關于正态分布資料的栗子:

gnuplot 繪圖可采用txt 文本文檔也可采用dat 資料文檔,gnuplot 支援很多繪畫樣式,set style data 和set style function 指令修改預設的繪畫樣式,在plote 或splot 指令内使用選項指定繪畫樣式,如果在一條plot 語句上繪制多個圖形,那麼要對每個圖形指定繪畫樣式,例如plot ”result1.dat” with boxes ,”result1.dat” with line,with 後接繪畫樣式,boxes 是直方圖(隻能用于2D)接受2,3 輸入列,第一列對應x、第二列對應y、第三列對應x 寬度(預設則為預設值)。lines 是折線,依次連接配接每個點,可采用smooth 平滑選項産生不同的拟合效果(unique 相同橫坐标取中點使之x 軸單調、bezier n 級貝塞爾曲線拟合、cspline 先進行了unique 再采用三次樣條曲線拟合連接配接、),每個樣式對自己的資料集有不同的要求,例如預設的lines 樣式需要一個值做為y,使用自動生成的x,或者使用資料庫中的x,其他更多樣式不做過多說明。詳細參閱gnaplot 手冊http://www.doc88.com/p-1761985525506.html。

在Windows 中設定好環境變量,在cmd 視窗中輸入gnuplot 進入gnuplot 繪圖模式,plot

”result1.txt” title ”data point”, ”result1.dat” with boxes lt -1 title ”data boxes”,”result1.dat” with lines smooth csplines lt 0 title ”data lines” ,plot(繪制)”result1.txt”(文本檔案)title (命名為)”data point”,(及)(資料檔案)”result1.dat” with boxes(直方圖)lt -1(線型為-1) title(命名為)”data boxes”,(及)”result1.dat”(資料檔案)with lines(曲線)smooth csplines (平滑拟合)lt 0 (線型0)title (命名為)”data lines”

指令行采用gnuplot 運作繪制直方圖及曲線語句如下圖:

gnuplot使用備忘

指令行采用gnuplot 運作繪圖語句繪制直方圖及曲線如下圖:

gnuplot使用備忘

繼續閱讀