Gnuplot–linux下的畫圖工具

來源:互聯網
上載者:User
Gnuplot 是一種免費的繪圖工具,可以移植到各種主流平台。它可以下列兩種模式之一進行操作:當需要調整和修飾圖表使其正常顯示時,通過在 gnuplot 提示符中發出命令,可以在互動模式下操作該工具。或者,gnuplot 可以從檔案中讀取命令,以批處理模式組建圖表。
在shell中敲打"gnuplot", 進入到gnuplot編輯環境裡
初級基礎命令:
1. set terminal  postscript
設定終端
2. set xlabel 'x-date'
x座標軸的名字為"x-date"
3. set title "demo"
該圖的名字為"demo"
4. set key top left
    set key box
設定圖例的位置和形狀
5. set output '/test/aa.ps'
設定圖片儲存到的檔案目錄
6. set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"
設定x座標軸資料的格式
7.plot ["17:39:31":"17:50:48"] '/var/log/dns.log' using 1:2 title "test" with lines linetype 1
畫圖, x座標起點是"17:39:31", 終點是"17:50:48", 源檔案為'/var/log/dns.log' , 使用該檔案的第一列和第二列資料作圖,畫直線圖

8. 例子:
set xlabel 'x-time'
set ylabel 'y-%'
set mxtics 1
set title "cpu data analysis"
set key top left
set key box
set term post eps color solid enh
set output '/export/home/nancy/cpu.eps'
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"
 plot  ["17:39:31":"17:50:48"] '/export/home/nancy/cpu' using 1:2 title "usr" with line
s linecolor rgb "yellow", '/export/home/nancy/cpu' using 1:3 title "sys" with line linecolor r
gb "red" , '/export/home/nancy/cpu' using 1:4 title "w" with line linecolor rgb "blue", '/expo
rt/home/nancy/cpu' using 1:5 title "idle" with line linecolor rgb "green"

9. 寫成指令碼直接運行
把8中的命令寫到*.plt檔案裡, 可以gnuplot>load ‘a.plt’, 若只想產生ps或eps檔案, 則可以直接在shell下運行gnuplot a.plt

10. ps和eps
ps:產生pft檔案
eps:可以直接插入到word/execel 檔案中.

11. 目前還有個小問題沒有解決---已解決,更新例子(8)
當我在一個圖中畫多條線時, 如何使用不同的顏色來加以區分

12. 有用的文章
http://www.ibm.com/developerworks/cn/linux/l-gnuplot/index.html
http://cycloid.blog.163.com/blog/static/8847862006823102056295/
http://dsec.pku.edu.cn/dsectest/dsec_cn/gnuplot/ (gnuplot 中文手冊)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.