2012-05-30 9 views
7

पर अपरिभाषित:सभी बिंदुओं y मूल्य क्यों जब मैं gnuplot के लिए इस कोड को यह काम है 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 

एक्स का पहला बिंदु 1 है, एक्स के दूसरे बिंदु 2 है, और पिछले है 3. अब मैं यह 1, 2, 3 पैमाने 50, 55 से 60 represente करना चाहते हैं !

+0

'../ myFile.final' की सामग्री क्या हैं? – mgilson

+0

यह वर्तमान निर्देशिका के बाहर है! मेरी सामग्री का एक तरीका सच है! – Mehdi

उत्तर

16

कुछ ऐसी चीजें हैं जो यहां गलत हो सकती हैं - आपके डेटाफाइल को देखे बिना यह बताना असंभव है। एक जोड़े जो मैं अपने सिर के ऊपर से सोच सकते हैं कर रहे हैं:

सभी कॉलम 2 में अपने datapoints हैं सब कम से कम या बराबर 0

(आप त्रुटि संदेश क्योंकि लॉग (0) अपरिभाषित है मिलता है)

आप 50 और 100 के बीच पहले कॉलम इस मामले में किसी भी अंक नहीं हैं, अपने सभी datapoints साजिश सीमा से बाहर काटा गया हो की वजह से set xrange [50:100]

आपका datafile केवल 1 स्तंभ है ... इस मामले में , gnuplot किसी भी वाई-मान नहीं देखता है। (plot '../myFile.final' u 1 ... करने के लिए परिवर्तन)

संपादित

, ठीक है अब है कि मैं अपने datafile देखते हैं, समस्या निश्चित रूप से है कि आप 0 से 2 (gnuplot से datafile अनुक्रमण शुरू होता है के लिए set xrange [50:60] लेकिन अपने डेटा की xrange केवल चलाता है है 0)। इसे ठीक करने का सबसे आसान तरीका छद्म-कॉलम 0 का उपयोग करना है। छद्म-कॉलम 0 बस 0 से शुरू होने वाली लाइन संख्या है (यदि आप plot 'blah.txt' using 1 करते हैं तो एक्स अक्ष पर 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 है - [तीन अंक, 0,1,2])। यदि आप डेटापॉइंट्स की संख्या नहीं जानते हैं, तो आप शैल जादू का उपयोग कर सकते हैं, या सीधे gnuplot से। पहला तरीका थोड़ा आसान है, हालांकि पोर्टेबल के रूप में नहीं।

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 अधिकतम लेने की जरूरत है::

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" 

मैं पूर्णता के लिए लगता है, मुझे लगता है कि कहना चाहिए मैं दोनों दिखाता हूँ gnuplot 4 में करना भी आसान है।

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 बहुत अच्छा लग रहा है: 6 (मैं अभी स्थापित नहीं है, तो यह अगले भाग सिर्फ डॉक्स की मेरी समझ से आता है)। मैं शायद इसके साथ जल्द ही खेलना शुरू कर दूंगा।

+0

मैंने अपनी पोस्ट संपादित की है :) – Mehdi

+0

@ मेहदी - मैंने अपनी पोस्ट भी संपादित की है। यह बहुत विस्तृत है, लेकिन उम्मीद है कि यह पर्याप्त समझ में आता है। – mgilson

+0

ग्रेट यह काम है, आखिरी सवाल कृपया: जब आप बनाते हैं: 'plot 'test.dat' का उपयोग करके (scale_x ($ 0,50,60, XMIN, XMAX)): 1' इसका क्या अर्थ है:' 1 ' – Mehdi