2014-06-08 1 views
3

로부터 저장 데이터 I는 (N = 1000) 실수의 균일 한 랜덤 분포의 간단한 누적 히스토그램 플롯합니다GNUPLOT : 매끄러운 누적

http://www.filedropper.com/random1_1 :

그리고 매크로는 random1.dat :

unset key 
clear 
reset 


n=120 #number of intervals 
max=4. #max value 
min=1. #min value 

width=(max-min)/n #interval width 
#function used to map a value to the intervals 
bin(x,width)=width*floor(x/width)+width/2.0 # cosi viene centrato in mezzo 
set xtics min,(max-min)/10,max 
set boxwidth width 
set style fill solid 0.5 border 


set ylabel 'Frequency' 
set y2label 'Cumulative frequency' 
set y2tics 0,100,1000 
set ytics nomirror 

set xrange [0.9:4.1] 
set yrange [0:25] 

set terminal pngcairo size 800,500 enhanced font 'Verdana,14' 
set output "testCum.png" 

plot 'random1.dat' using (bin($1,width)):(1.0) smooth frequency with boxes title 'histogram',\ 
'' using (bin($1,width)):(1.0) smooth cumulative axis x1y2 w l lt 2 lw 2 lc rgb 'green' title 'cumul' 

이제 output.png은 다음과 같습니다

enter image description here

,

나는 Gnuplot에게 어떻게 누적 줄거리뿐만 아니라 특정 파일에 저장되어있는 숫자도 가져 가고 싶습니다 .dat?

답변

4

smoothset table ...을 적용한 후 데이터를 저장할 수 있습니다. 당신은 단지 누적 데이터가 필요한 경우 간단한 경우, 단지 사용

set table 'random1-smoothed.dat' 
plot 'random1.dat' using (bin($1,width)):(1.0) smooth cumulative 
unset table 

은 스크립트에서 더 나은 포함 당신은 또한 기존의 전체를 포장 할 수 plot 명령 set table에서 :

... 
set table 'random1-smoothed.dat' 
plot 'random1.dat' using (bin($1,width)):(1.0) smooth frequency with boxes title 'histogram',\ 
'' using (bin($1,width)):(1.0) smooth cumulative axis x1y2 w l lt 2 lw 2 lc rgb 'green' title 'cumul' 
unset table 

set terminal pngcairo size 800,500 enhanced font 'Verdana,14' 
set output "testCum.png" 
replot