2012-05-30 6 views
7

에 정의되지 않은 :모든 점 Y 값의 gnuplot

set terminal postscript enhanced color 
set output '../figs/ins_local.ps' 

set title "Result" 

set logscale y 
set xrange [50:100] 
set xtics 5 

#set xlabel "Insertion" 
#set ylabel "Time (in microseconds) " 

plot sin(x) 

하지만 난에 plot sin(x)을 변경할 때 :

:

plot "../myFile.final" with lines title "Somethings" lw 3 linecolor rgb "#29CC6A" 

이 오류가

plot "../myFile.final" with lines title "Somethings" lw 3 linecolor rgb "#29CC6A" 
                          ^
"local.gnuplot", line 16: all points y value undefined 

저는 하나의 열이 있습니다! 그것은 yrange을 대표한다. xrange은 라인 수로 표시됩니다! 내 데이터 포인트의 예 :

125456 
130000 
150000 
X의

첫번째 포인트는, (X)의 제 점 2, 1이고, 마지막으로 3. 지금이 1, 스케일 (50), (55) 2, 3, 60 represente 할 것이다 !

+0

'../ myFile.final'의 내용은 무엇입니까? – mgilson

+0

현재 디렉토리 밖입니다! 내 콘텐츠의 방법은 사실입니다! – Mehdi

답변

16

여기에 잘못 될 수있는 몇 가지가 있습니다. 데이터 파일을 보지 않고도 말할 수 없습니다. 난 내 머리 위로 떨어져 생각할 수있는 몇 가지 있습니다 : 2 열의

귀하의 모든 데이터 포인트를 모두 덜

같거나 0 (로그 (0) 정의되지 않기 때문에 당신은 오류 메시지)보다

첫 번째 열에 50과 100 사이의 포인트가 없습니다.이 경우, 모든 데이터 포인트가 플롯 범위 밖으로 벗어납니다. 왜냐하면 set xrange [50:100]

데이터 파일에 1 열만있는 경우 ...이 경우 , gnuplot은 y 값을 보지 못합니다. (plot '../myFile.final' u 1 ...로 변경) 지금은 당신의 데이터 파일을 볼 것을,

확인

편집, 문제는 0에서의 gnuplot부터 데이터 파일 인덱싱을 시작합니다 2 (에 xrange 만 실행 set xrange [50:60]하지만 데이터의를했습니다 것을 확실히 0). 이를 해결하는 가장 쉬운 방법은 의사 열 0을 사용하는 것입니다. 의사 열 0은 단순히 0에서 시작하는 행 번호입니다 (plot 'blah.txt' using 1을 입력하면 x 축의 gnuplot이 그려집니다). 다음 예가 있습니다 :

scale_x(x,xmin,xmax,datamin,datamax)=xmin+(xmax-xmin)/(datamax-datamin)*x 
plot 'test.dat' using (scale_x($0,50,60,0,2)):1 w lines title "scaled xrange" 
당신이 사용하는 사양이 어떻게 작동하는지 모르는 경우

주, $ 앞에 숫자는 전체 열에 요소 현명한 작업 것을 예를 들면 다음과 같습니다.

plot 'foo.bar' using 1:($2+$3) 

가 첫 번째 열을 더한 합계를 플롯합니다 데이터 파일의 각 행에있는 두 번째 및 세 번째 요소

이 솔루션은 데이터 파일에서 x의 최대 값을 알고 있다고 가정합니다 (이 경우 3-1 = 2 - [3 points, 0,1,2]). 데이터 포인트의 수를 모르는 경우 쉘 마술을 사용하거나 gnuplot에서 직접 얻을 수 있습니다. 첫 번째 방법은 이식성이 아니더라도 조금 쉽습니다. 나는 그 말을해야

set term push #save terminal settings 
set term unknown #use unknown terminal -- doesn't actually make a plot, only collects stats 
plot 'test.dat' u 0:1 #collect stats 
set term pop #restore terminal settings 
XMIN=GPVAL_X_MIN #should be 0, set during our first plot command 
XMAX=GPVAL_X_MAX #should be number of lines-1, collected during first plot command 
scale_x(x,xmin,xmax,datamin,datamax)=xmin+(xmax-xmin)/(datamax-datamin)*x 
plot 'test.dat' using (scale_x($0,50,60,XMIN,XMAX)):1 w lines title "scaled xrange" 

내가 완전성에 대한 가정 :

XMAX=`wc -l datafile | awk '{print $1-1}'` 
scale_x(x,xmin,xmax,datamin,datamax)=xmin+(xmax-xmin)/(datamax-datamin)*x 
plot 'test.dat' using (scale_x($0,50,60,0,XMAX)):1 w lines title "scaled xrange" 

두 번째 방법은, 우리가 데이터를 통해 두 패스를하고하자의 gnuplot 최대를 선택해야합니다 : 둘 다 보여 드리죠 이것은 gnuplot 4에서 더 쉽게 할 수 있습니다.6 (나는 지금 설치되어 있지 않기 때문에이 다음 부분은 바로 문서에 대한 이해에서 비롯됩니다) :

stats 'test.dat' using 0:1 name "test_stats" 
#at this point, your xmin/xmax are stored in the variables "test_stats_x_min"/max 
XMIN=test_stats_x_min 
XMAX=test_stats_x_max 
scale_x(x,xmin,xmax,datamin,datamax)=xmin+(xmax-xmin)/(datamax-datamin)*x 
plot 'test.dat' using (scale_x($0,50,60,XMIN,XMAX)):1 w lines title "scaled xrange" 

의 gnuplot 4.6은 정말 멋진 보인다. 나는 곧 그걸 가지고 놀아 볼거야.

+0

내 게시물을 편집했습니다. – Mehdi

+0

@Mehdi - 내 게시물도 편집했습니다. 그것은 꽤 상세하지만, 충분히 이해할 만하다. – mgilson

+0

마지막 질문입니다. 'plot 'test.dat'(scale_x ($ 0,50,60, XMIN, XMAX)) 사용 : 1' 무엇을 의미합니까? '? – Mehdi