歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Gnuplot繪制圖形並保存為圖片

Gnuplot繪制圖形並保存為圖片

日期:2017/3/1 10:00:42   编辑:Linux編程

環境:Fedora12

當用gnuplot科學繪圖時,在shell中進入gnuplot,一行一行的進行繪制,比較麻煩,我們可以將每種繪制命令統一放入一個文件中,然後利用gnuplot加載這個plot文件即可。示例如下所示:

1.繪制圖形的plot文件sinx.plt

#################保存結果為圖片:方式一,該方式保存有多張圖片,包括中間結果圖片
#set term post color
#set output 'a.ps'
################
plot sin(x)
set grid
set xlabel "X"
set ylabel "Y"
replot
################保存結果為圖片:方式二,該方式保存的為最終繪制成的圖片
set terminal postscript eps color
set output './gnuplot_result/sin.eps' #可以指定保存路徑,該示例保存在了當前路徑中的gnuplot_result文件中
replot
set output
################

2.shell命令行中輸入"gnuplot sinx.plt",繪制了圖形,並保存到了指定路徑中。

更多Fedora相關信息見Fedora 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=5

Copyright © Linux教程網 All Rights Reserved