Plotting w/ Gnuplot

เคยได้ยินมานานแล้วว่าเวลาจะพล็อตกราฟ เค้านิยมใช้ Gnuplot กัน แต่ก็แค่เคยได้ยิน เพราะไม่เคยได้ใช้งานที่มันต้องพล็อตกราฟจริงๆ จังๆ ซักหน อย่างมากใช้แค่โปรแกรม SpreadSheet ทั่วไปก็เพียงพออยู่แล้ว แต่พอดีวันนี้มีความต้องการใช้การพล็อตกราฟจากสมการที่เป็น function ของ x หลายๆ สมการเทียบกัน แล้วก็ขี้เกียจเปิดโปรแกรม SpreadSheet ขึ้นมาใช้ เลยพยายามลองใช้ Gnuplot ดู

โชคดีที่ Gnuplot มีให้ใช้งานทั้งบน windows, linux แล้วก็ mac วิธีการติดตั้งบน mac ก็ไม่ยากอะไร แค่รันผ่านทาง fink เท่านั้นเอง

Tabris:~ pittaya$ apt-cache show gnuplot
Package: gnuplot
Source: gnuplot
Version: 4.0.0-1005
Priority: optional
Section: sci
Maintainer: Jeffrey Whitaker <jswhit @fastmail.fm>
Depends: libpng3-shlibs (>= 1.2.5-3), texinfo, aquaterm (>= 1.0.0-1002), aquaterm-shlibs (>= 1.0.0-1002), readline-shlibs (>= 4.3-1028), pdflib-shlibs (>= 5.0.1-1), x11, ncurses (>= 5.4-20041023-1006), libncurses5-shlibs (>= 5.4-20041023-1006), gd2-shlibs, libjpeg-shlibs, darwin (>= 8-1)
Architecture: darwin-i386
Filename: dists/fink-0.8.1/main/binary-darwin-i386//sci/gnuplot_4.0.0-1005_darwin-i386.deb
Size: 2438510
Installed-Size: 6320
MD5sum: ff5fe43474e8491e0ab3c088477bec4a
Description: Command-driven interactive plotting program
It can be used to plot functions and data points in both two- and
three-dimensional plots in many different formats, and will accommodate
many of the needs of today's scientists for graphic data representation.
.
Web site: http://www.gnuplot.info/

Tabris:~ pittaya$ apt-get install gnuplot

library ที่จำเป็นต้องใช้งานส่วนใหญ่ก็มีอยู่แล้ว ยกเว้น Aquaterm ที่ไม่ได้ลงไว้ fink ก็จะไปโหลดมาลงให้เอง สะดวกสบายดี

ติดตั้งเสร็จแล้วก็อ่านวิธีใช้แบบคร่าวๆ จาก Tutorial พอให้ทำงานได้

วาดกราฟตรีโกณใช้แค่คำสั่งนี้ที่ shell ของ gnuplot
gnuplot> plot sin(x), cos(x), tan(x)

ง่ายกว่าที่คิด

One Comment

  1. แข says:

    พิท แขขอประชาสัมพันธ์หน่อยนะ
    เผื่อมีใครสนใจ
    http://weerasak.com/?p=848

Leave a Reply