Article:
GnuPlot - Chương trình vẽ đồ thị
1306
saigon.myopenid.com 8Updated over 2 years ago |
Gnuplot là một phần mềm miễn phí, dùng để vẽ đồ thị các hàm toán học, hoặc từ tập dữ liệu sẵn có. Phần sau đây sẽ hướng dẫn cách cài đặt và sử dụng vài hàm cơ bản của gnuplot.

Cài đặt Gnuplot
Download gnuplot-4.2.5.tar.gz từ http://www.gnuplot.info/download.html, đặt vào /tmp
cd /tmp
tar xzf gnuplot-4.2.5.tar.gz
cd gnuplot-4.2.5
./configure
sudo make
sudo make install
gõ lệnh gnuplot:
% gnuplot
G N U P L O TVersion 4.0 patchlevel 0
last modified Thu Apr 15 14:44:22 CEST 2004
System: Linux 2.4.23
Copyright (C) 1986 - 1993, 1998, 2004
Thomas Williams, Colin Kelley and many others
This is gnuplot version 4.0. Please refer to the documentation
for command syntax changes. The old syntax will be accepted
throughout the 4.0 series, but all save files use the new syntax.
Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from
http://www.gnuplot.info/faq/
Send comments and requests for help to
Send bugs, suggestions and mods to
Terminal type set to 'x11'
gnuplot>
Thử vẽ đồ thị hàm sin(x)
gnuplot> plot sin(x)

Vẽ đồ thị từ dữ liệu có sẵn
Tạo file dữ liệu
vi data.dat
40 0.134
60 0.130
80 0.127
100 0.129
120 0.138
130 0.153
gnuplot> plot "data.dat" with lines
gnuplot>

Ta cũng có thể add thêm title, tên truc tung, trục hoành, sử dụng lệnh replot để vẽ lại đồ thị
gnuplot> set xlabel "user"
gnuplot> set ylabel "second"
gnuplot> set title "thoi gian truy cap"
gnuplot> replot
Tham khảo thêm về gnuplot tại http://t16web.lanl.gov/Kawano/gnuplot/index-e.html
8