<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                幾年前寫的一篇短文,今天找東西時翻出來了,感覺寫的還是比較實用的。放在這里供有需要的人參考。 現在在網上可以找的科學作圖軟件有不少,其中不乏優秀者,Win平臺上有大名鼎鼎的Origin、Tecplot、SigmaPlot等,類UNIX上有LabPlot、gnuplot等。其他的常見的計算軟件如Matlab、Mathematica、Maple、Scilab、IDL、Maxima等也都對科學作圖有很好的支持,甚至于只要稍加努力使用MS的Excel也可以做出不錯的圖來。但是筆者最喜愛的工具還是gnuplot。gnuplot?是典型的UNIX?哲學的產物,小巧,靈活,擅長于與其他工具協同工作。本人使用gnuplot?已經有1年有余,積累了些經驗,下面的內容主要是我1年多來使用gnuplot所做筆記的一個總結,當然,在成稿過程中也將gnuplot?的手冊又來回翻了幾遍。 gnuplot是一個命令行驅動的科學繪圖工具,可將數學函數或數值資料以平面圖或立體圖的形式畫在不同種類終端機或繪圖輸出裝置上。它是由Colin?Kelley?和?Thomas?Williams于1986年開發的繪圖程序發展而來的,可以在多個平臺下使用。gnuplot既支持命令行交互模式,也支持腳本。 gnuplot?的主要作者包括:Thomas?Williams,?Colin?Kelley,?Russell?Lang,?Dave?Kotz,?John?Campbell,?Gershon?Elber,?Alexander?Woo?和許多其他人。 gnuplot?與自由軟件基金會和GNU?項目沒有任何直接的關系,因此將?gnuplot?稱為?GNUplot?是不對的。gnuplot?是完全獨立的設計和開發的,命名為?gnuplot?只是種妥協,當時Thomas?希望他們開發的程序叫做?"llamaplot"?而Colin?更喜歡?"nplot"?這個名字。后來他們都同意命名他們的程序為?"newplot",可是很快他們發現有個Pascal?語言寫的程序叫這個名字,而且這個程序偶爾會被提到。最后?Thomas?想出了"gnuplot"?這個雙方都可以接受的名字。? gnuplot?在互聯網上的主頁地址是:[www.](http://www.gnuplot.info/)gnuplot.info?,?源代碼和可執行程序也可以到[http://sourceforge.net/projects/](http://sourceforge.net/projects/gnuplot)gnuplot?上下載。 gnuplot有詳細的使用手冊,如果用戶使用的是GNU/Linux操作系統,可以察看?/usr/share/doc/gnuplot目錄下的gnuplot.html文件。需要PDF版本的使用手冊可以到[http://sourceforge.net/projects/](http://sourceforge.net/projects/gnuplot)gnuplot?下載。 本文中所引用范例皆整理自?gnuplot?demo。文中的圖例亦引用自子目錄?demo?中的范例。 # 快速入門 本文全文都以GNU/Linux?下的?gnuplot?4.0版本為例,如果讀者使用的是其他版本的操作系統,個別操作細節請做相應調整。 在命令行模式下輸入?gnuplot,即可看到如下的信息,其中省略號處省略了部分信息: ~~~ G N U P L O T Version 4.0 patchlevel 0 last modified Thu Apr 15 14:44:22 CEST 2004 System: Linux 32 bit …… Terminal type set to 'x11' gnuplot> ~~~ ‘gnuplot>’即是?gnuplot?的命令行提示符,gnuplot?的所有命令都在這個提示符下輸入。 ### 2D?繪圖 請看例?1: ~~~ plot sin(x) ~~~ 產生圖?2結果?——以曲線繪出三角函數?sin(x)。? ![](https://box.kancloud.cn/2016-01-24_56a4234051801.PNG) 圖?1?Plotting?sin(x) 假設我們只想看到一個正弦曲線周期。我們通過限制圖的默認?x?范圍來完成此操作。使用表示法?[min:max]?來指定范圍。要僅指定最小值,使用?[min:];要僅指定最大值,使用?[:max]。數學上稱此為所謂的“閉”區間表示法。 例?2從?-pi?到?+pi?的?sin(x)?和?cos(x) ~~~ set xrange [-pi:pi] replot cos(x) with points pointtype 2 ~~~ 或者: ~~~ plot [-pi:pi] sin(x), cos(x) with points pointtype 2 ~~~ ![](https://box.kancloud.cn/2016-01-24_56a42340637ce.PNG) 我們剛才使用了?replot?命令,它執行先前的?plot?命令。當您繪制曲線圖且需要不斷對該圖進行修改以添加想要的特征時,此命令會非常有用。另外,replot?使您可以添加更多的圖。嘗試輸入?replot?cos(x)。依照語法,該命令等同于?plot?sin(x),?cos(x)。replot?就是獲取先前的繪圖字符串,添加必要的逗號,然后附加輸入給它的其余部分。 例?5?將數據文件中的數據畫出: ~~~ plot sin(x), ‘1.dat’ ~~~ 其中1.dat?為一數據文件,每一行描述一點坐標位置。?內容如下,其中?#?后面的內容為注釋:? ~~~ # $Id: 1.dat,v 1.1.1.1 1998/04/15 19:16:40 lhecking Exp $ -20.000000 -3.041676 -19.000000 -3.036427 -18.000000 -3.030596 -17.000000 -3.024081 -16.000000 -3.016755 -15.000000 -3.008456 …… ~~~ ![](https://box.kancloud.cn/2016-01-24_56a42340742ea.PNG) 圖 2?Plotting?sin(x),?data?file?–?1.dat 例?6命名圖和坐標軸: ~~~ set title 'My first graph' set xlabel 'Angle, in degrees' set ylabel 'sin(angle)' plot sin(x) ~~~ ![](https://box.kancloud.cn/2016-01-24_56a4234082bf5.PNG) 現在,我們注意到?x?軸實際沒有標記為度數,看起來不是很好。要修改此問題,可以通過調整?x?軸上的?tic?標記。 例?7?改變軸上?tic?并設置網格: ~~~ set title "My first graph" set xrange [-pi:pi]  # we want only one cycle set xtics ('0' 0, '90' pi/2, '-90' -pi/2, '45' pi/4,'-45' -pi/4,'135' 3*pi/4,'-135' -3*pi/4) set grid set xlabel 'Angle, in degrees' set ylabel 'sin(angle)' plot sin(x) ~~~ ![](https://box.kancloud.cn/2016-01-24_56a42340904f3.PNG) gnuplot?還允許您指定繪圖的樣式,以便獲得進一步的控制。 例?8?多條曲線 ~~~ plot sin(x) with linespoints pointtype 5, cos(x) w boxes lt 4 ~~~ ![](https://box.kancloud.cn/2016-01-24_56a423409ed72.PNG) with?子句使您可以詳細而精確地指定線的樣式。在本例中,我們說明兩種有用的樣式。第一種樣式?linespoints?通常在對數據繪圖時非常有用,它在涉及的每個示例或數據點處標記一個點,并使用線性插值法連接連續的點。這里我們另外指定點類型為?5,它選擇終端允許的第五種點。第二種樣式?boxes?更適合繪制直方圖數據。注意我們如何在?cos(x)?曲線中將?with?縮寫成?w。類似地,lt?是?linetype?的縮寫,是另一個特定于終端的設置,它選擇終端可以繪制的四種線。不必說,您可以使用?pt?代替冗長的?pointtype。如果想在多條線中使用相同的繪圖樣式(在一個?plot?命令中或在多個?plot?命令中),可以使用?set?命令設置繪圖樣式:set?style?function?linespoints。要更改用于繪制與函數相對的數據集合的樣式,使用?set?style?data?linespoints。 當繪制兩條或多條曲線時,我們需要關鍵字或圖例來對它們進行區分。默認情況下,關鍵字在右上角;但是如果它妨礙了圖,可以將關鍵字放到其他位置?。如果愿意,甚至可以放到圖外。 例?9?定制圖的關鍵字或圖例 ~~~ set key top left set key box plot [-pi:pi] sin(x) title 'sinusoid' with linespoints pointtype 5, cos(x) t 'cosine' w boxes lt 4 ~~~ ![](https://box.kancloud.cn/2016-01-24_56a42340af711.PNG) 上面,我們在同一圖中繪制了正弦和余弦曲線。gnuplot?使您還可以繪制多個圖,這樣它們可以并排顯示在同一輸出屏幕或文件中。在某些排版系統中,以一個文件的形式包含兩個圖形比分別包含兩個圖形要更容易。 例?10?Multiplot?示例: ~~~ set xrange [-pi:pi] # gnuplot recommends setting the size and origin before going to multiplot mode # This sets up bounding boxes and may be required on some terminals set size 1,1 set origin 0,0 # Done interactively, this takes gnuplot into multiplot mode set multiplot # plot the first graph so that it takes a quarter of the screen set size 0.5,0.5 set origin 0,0.5 plot sin(x) # plot the second graph so that it takes a quarter of the screen set size 0.5,0.5 set origin 0,0 plot 1/sin(x) # plot the third graph so that it takes a quarter of the screen set size 0.5,0.5 set origin 0.5,0.5 plot cos(x) # plot the fourth graph so that it takes a quarter of the screen set size 0.5,0.5 set origin 0.5,0 plot 1/cos(x) # On some terminals, nothing gets plotted until this command is issued unset multiplot # remove all customization reset ~~~ ![](https://box.kancloud.cn/2016-01-24_56a42340c009a.PNG)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看