gnuplot의 사용

4544 단어 드로잉gnuplot
plot 명령 형식:
Syntax:
       plot {[ranges]}
            {[function] | {"[datafile]"
       {datafile-modifiers}}}
            {axes [axes] } { [title-spec] } {with [style] }
            {, {definitions,} [function] ...}

plot 데이터 파일.예제 파일 a.txt의 내용 일부입니다.
1 611738 581056 593414 583590 502984 553813
2 661569 548566 556251 503663 461451 507295
3 723006 558036 518351 461444 429248 464006
4 748299 579828 510268 432925 403245 444233
5 770639 630340 558121 428781 409407 447517
6 773501 663703 580150 430565 414668 454168
7 773358 680100 602547 429561 415999 459455
8 772250 693620 616986 424956 416455 461635
9 767792 714011 642304 419132 413608 464747
10 760577 729287 666633 410204 416556 464428
...
gnuplot> plot "data.txt" using 1:2

using1:2는 첫 번째 열로 x 좌표를 표시하고 두 번째 열로 y 좌표를 표시합니다.
gnuplot> plot [0:100] [0:800000] "a.txt" using 1:2

x 좌표의 범위는 0에서 100, y 좌표의 범위는 0에서 800000을 가리킬 수 있다.아래의 방법과 마찬가지로 같은 기능을 실현할 수 있다.
gnuplot> set xrange [0:100]
gnuplot> set yrange [0:800000]
gnuplot> plot "a.txt" using 1:2

타이틀로 곡선의 이름을 지정할 수 있습니다.
gnuplot> plot "a.txt" using 1:2 title "sample curve" ;

쓸만하다
gnuplot> plot "a.txt" using 1:2 with lines #  
gnuplot> plot "a.txt" using 1:2 with points #  
gnuplot> plot "a.txt" using 1:2 with linespoints #  

다음 예는 두 곡선을 동시에 표시할 수 있는데 각각 점과 선의 방식을 사용할 수 있다.
gnuplot> plot sin(x) with lines title 'Sine Function', \
     tan(x) with points title 'Tangent'

다음 예는 서로 다른 색으로 선을 표시할 수 있다.
gnuplot> plot sin(x) with lines linetype 1

다음 예에서는 선의 폭을 지정하는 방법을 설명합니다.
gnuplot> plot sin(x) with lines linewidth 6

포인트 type과pointsize로 점을 지정할 수 있는 색깔과 크기와 유사합니다.
테스트 명령으로 지원되는 모든 linetype,linewidth,point type,pointsize를 볼 수 있습니다.
아래의 방법으로 라인과point의 모양을 지정할 수도 있습니다.
gnuplot> plot "a.txt" using 1:2 with linespoints linestyle 1
gnuplot> set style line 1 linetype 2 linewidth 1 pointsize 2 pointtype 6
gnuplot> replot
gnuplot> set style line 1 linetype 2 linewidth 1 pointsize 2 pointtype 4
gnuplot> replot
gnuplot> set style line 1 linetype 2 linewidth 1 pointsize 2 pointtype 11
gnuplot> replot

다음 예에서는 X Y 좌표의 이름을 지정하는 방법을 설명합니다.
gnuplot> set xlabel "time(t)"
gnuplot> set ylabel "A"
gnuplot> plot sin(x)


다음 명령으로 테두리를 처리할 수 있습니다.
gnuplot> unset border #  
gnuplot> set border 1 linetype 2 #   linetype 2
gnuplot> replot
gnuplot> set border 2 linetype 3 #   linetype 3
gnuplot> replot
gnuplot> set border 3 linetype 3 #   line type 3

border 뒤의 숫자는 12개bit의 정수이며, 각각bit는 테두리를 표시합니다.그래서 1, 2, 4, 8은 각각 아래, 왼쪽, 위, 오른쪽 테두리에 대응한다.
set grid로 배경 격자선을 제어할 수 있습니다.도움말 보기 help set grid
gnuplot> set grid
gnuplot> unset grid

set 키를 사용하여 커브 이름의 배치 위치를 제어할 수 있습니다.도움말help set 키 보기
gnuplot> plot sin(x) title "Sine X"
gnuplot> set key top left
gnuplot> replot

아래의 방법으로 표시를 하나 추가할 수 있다.도움말 보기 help set arrow, help set label
gnuplot> set label 1 "Peak" at -5,0.8 right
gnuplot> set arrow 1 from -5,0.8 to -0.9,0.9 head
gnuplot> replot

아래의 방법으로 그림에 제목을 추가할 수 있다.도움말 보기 help set title
gnuplot> set title "My Figure 1"
gnuplot> replot

아래의 방법으로 좌표의 각도 표시를 제어할 수 있다.도움말 보기 help set xtics
gnuplot> set xtics ("left" -5, "middle" 0, "right" 5);
gnuplot> set ytics ("max" 1, "zero" 0, "min" -0.2);
gnuplot> plot [-10:10] [-1:2] sin(x)/x

다음 방법으로 데이터 파일의 두 번째 열과 세 번째 열의 합을 처리한 데이터를 볼 수 있습니다.
gnuplot> plot "a.txt" using 1:($2+$3), "a.txt" using 1:2,"a.txt" using 1:3

다음 방법으로 그림을 jpeg 형식으로 출력할 수 있습니다.
$echo "set terminal jpeg small ; plot sin(x)" | gnuplot  > a.jpg

외부 명령으로 처리된 데이터plot 가능
gnuplot> plot "< awk '{print $1,$2+$3,$2}' < a.txt" using 1:2

좋은 웹페이지 즐겨찾기