'gnuplot'에 해당되는 글 2건

  1. 2010.03.20 gnuplot 코드 모음1
  2. 2009.10.11 gnuplot 설치 as user
  3. .
gnuplot2010. 3. 20. 14:13
학부 4학년 2학기에 작성했던 코드.
ns2 시뮬레이션 결과를 그리려고 했던 것이다.
여러 데이터에 대해 그래프를 그려야 되는데 매번 그리기도 어려우므로 이런 식으로 했다.
사실 gnuplot 사용법도 되지만 bashrc 사용법도 된다.
bashrc에서 루프나 변수 사용은 매번 헷갈리므로

hw4.sh
그래프 다섯 개를 그렸다.
#! /bin/bash
rm -f hw4.log
for i in 50 1000; do # paket size
    for j in 0 2000; do # RTS Threshold
        # clean data files
        rm -f node0.dat
        rm -f node1.dat
        rm -f total.dat
        for k in {1..5}; do # N
            # run ns
            ns hw4.tcl $k $i $j
        done
        mv total.dat total_${i}_$j.dat
        # Plot
        echo > hw4.plot
        echo "set term png" >> hw4.plot
        echo "set grid" >> hw4.plot
        echo "set key default" >> hw4.plot
        echo "set xlabel \"\"" >> hw4.plot
        echo "set ylabel \"Mbps\"" >> hw4.plot
        echo "set xrange [0:6]" >> hw4.plot
        echo "set xtics 1,1,5" >> hw4.plot
        echo "set title \"hw4_${i}_$j\"" >> hw4.plot
        echo "set output \"hw4_${i}_$j.png\"" >> hw4.plot
        echo "plot \"node0.dat\" with linespoints title \"node0\", "\
        "\"node1.dat\" with linespoints title \"node1\"" >> hw4.plot
        echo "show output" >> hw4.plot
        gnuplot hw4.plot
    done
done
# Plot
echo > hw4.plot
echo "set term png" >> hw4.plot
echo "set grid" >> hw4.plot
echo "set key default" >> hw4.plot
echo "set xlabel \"\"" >> hw4.plot
echo "set ylabel \"Mbps\"" >> hw4.plot
echo "set xrange [0:6]" >> hw4.plot
echo "set xtics 1,1,5" >> hw4.plot
echo "set title \"hw4_total\"" >> hw4.plot
echo "set output \"hw4_total.png\"" >> hw4.plot
echo "plot \"total_50_0.dat\" with linespoints title \"50_0\", "\
"\"total_50_2000.dat\" with linespoints title \"50_2000\", "\
"\"total_1000_0.dat\" with linespoints title \"1000_0\", "\
"\"total_1000_2000.dat\" with linespoints title \"1000_2000\"" >> hw4.plot
echo "show output" >> hw4.plot
gnuplot hw4.plot

hw4.tcl은 주제와 과련이 없지만 그냥 적어둔다.

그림 그린 결과도 올린다.


hw3.sh도 비슷하다. unset border가 있는정도?
그래프 9 개를 그렸다.

hw2_2_3.sh는 다음과 같다.
무려 그래프 36 개를 그렸다. hw2를 보면 알겠지만 가장 먼저 작성한 코드.
36개를 수작업으로 그릴 수 없어서 이렇게 했던 것.


Posted by asdfzxcv
아직미분류2009. 10. 11. 15:18
root 권한 없이 gnuplot을 설치하는 방법이다. 물론 라이브러리들은 이미 있으면 설치할 필요가 없다. 참고로 libpng, libgd 등이 없어도 gnuplot은 사용할 수 있지만, gnuplot이 png 출력을 지원하게 하려면 필요하다. 물론 gnuplot이 아니더라도 비슷한 방법으로 의존 라이브러리를 설치하고 프로그램을 설치할 수 있을 것이다.

# install zlib

# install libpng
./configure --prefix=$HOME/usr
make check
make install
echo 'export C_INCLUDE_PATH=$HOME/usr/include:$C_INCLUDE_PATH' >> ~/.profile

# install libgd
./configure --prefix=$HOME/usr --with-png=$HOME/usr/lib
make
make check
make install

# gnuplot
./prepare # prepare가 없으면 무시해도 된다.
./configure --prefix=$HOME/usr --with-readline=gnu --with-gd=$HOME/usr/lib
make
# "make install" or "make install-strip"
make install-strip

참고로 gcc의 환경 변수로 다음과 같은 것들을 지정할 수 있다.
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
LIBRARY_PATH
더 많은 내용은...
http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Environment-Variables.html#Environment-Variables

Posted by asdfzxcv