gnuplot

不要把軟體名稱打錯,正確寫法是 gnuplot,開頭是 GNU,而非 GUN

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
jserv

安裝

# Linux install command sudo apt-get install -y gnuplot

檢查版本

$ gnuplot G N U P L O T Version 5.0 patchlevel 3 last modified 2016-02-21 Copyright (C) 1986-1993, 1998, 2004, 2007-2016 Thomas Williams, Colin Kelley and many others gnuplot home: http://www.gnuplot.info faq, bugs, etc: type "help FAQ" immediate help: type "help" (plot window: hit 'h') Terminal type set to 'qt' gnuplot>

測試畫圖

gnuplot 使用多種模式呈現圖

舉例來說上面出現Terminal type set to 'qt' 表示目前使用 qt 模式畫圖

但如果你沒安裝 qt 會顯示不出來

可以先用文字模式畫圖來測試 gnuplot 是否正常,先輸入 set terminal 檢查有哪些模式

gnuplot> set terminal Available terminal types: cairolatex LaTeX picture environment using graphicx package and Cairo backend canvas HTML Canvas object cgm Computer Graphics Metafile context ConTeXt with MetaFun (for PDF documents) corel EPS format for CorelDRAW dumb ascii art for anything that prints text dxf dxf-file for AutoCad (default size 120x80) eepic EEPIC -- extended LaTeX picture environment emf Enhanced Metafile format emtex LaTeX picture environment with emTeX specials epscairo eps terminal based on cairo epslatex LaTeX picture environment using graphicx package fig FIG graphics language for XFIG graphics editor gif GIF images using libgd and TrueType fonts gpic GPIC -- Produce graphs in groff using the gpic preprocessor hp2623A HP2623A and maybe others hp2648 HP2648 and HP2647 hpgl HP7475 and relatives [number of pens] [eject] imagen Imagen laser printer jpeg JPEG images using libgd and TrueType fonts latex LaTeX picture environment

可以看到 dump 就是用 ascii 模擬作圖

以下設定 dump 模式並畫一個範例圖,如果成功出現表示 gnuplot 正常

gnuplot> set terminal dumb gnuplot> set xzeroaxis gnuplot> set yzeroaxis gnuplot> plot [-2:2] acos(1-abs(x))-pi,sqrt(1-(abs(x)-1)**2) 2 ++-------+--------+--------+--------+-------+--------+--------+-------++ + + + + + + acos(1-abs(x))-pi ****** + | : sqrt(1-(abs(x)-1)**2) ###### | 1 ++ ###### : ###### ++ | ######### ########## : ########## ######### | | #### #### :#### #### | |# #### #| 0 *+....................................................................+* |* : *| | *** : *** | -1 ++ ***** : ***** ++ | ***** : ***** | | ***** : ***** | | ***** : ***** | -2 ++ ***** : ***** ++ | **** : **** | | *** :*** | -3 ++ **** ++ + + + + + + + + + +--------+--------+--------+--------+-------+--------+--------+--------+ -2 -1.5 -1 -0.5 0 0.5 1 1.5 2

現在改為 qt 模式測試

gnuplot> set terminal qt Terminal type set to 'qt' Options are '0 font "Sans,9"' gnuplot> set xzeroaxis gnuplot> set yzeroaxis gnuplot> plot [-2:2] acos(1-abs(x))-pi,sqrt(1-(abs(x)-1)**2) gnuplot>

會跳出畫好的圖案

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

參考文件

gnuplot 官方網站

tags Tool