2016-07-21 31 views
1

私はスペクトルをプロットする必要があります。さらに、いくつかの典型的なスペクトル線を示したいと思います。これは何千ものスペクトルのために自動的に生成されたスクリプトで行われるので、私は各スペクトルに表示する線を選択する可能性はなく、xrangeまたはyrangeの範囲で自動的に選択する必要があります。悲しいことに、この範囲は矢印のために働くようには見えないので、線がプロットの外側に表示されないようにするために、他の考えが必要です。私は条件付きで試してみましたが、これは変わっていません。ここ は、スクリプトからいくつか抜粋です:Gnuplot:矢印の範囲です。グラフの範囲の横に表示されないようにするにはどうすればよいですか?

set terminal png size 1000,1414 
set output "FeLoBAL_plot_1.png" 
set multiplot layout 4,1 title "FeLoBAL-Spektren des SDSS DR12" 
unset xrange 
unset yrange 
stats '170.txt' using 2 name "Fluss" nooutput 
stats '170.txt' using 1 name "A" nooutput 
set xlabel 'Wellenlaenge [{\305}]' 
set ylabel 'Fluss [erg/cm²/s/{\305}]' 
set yrange [-0.5:(Fluss_mean*3)] 
set xrange [(A_min/(1.699+1)):(A_max/(1.699+1))] 
p '170.txt' u (($1)/(1.699+1)):2 with lines title "Nr.: 170; J000256.55+092025.5; z=1.699" 
if(2799 > (A_min/(1.699+1)+20) && 2799 < (A_max/(1.699+1)-20)){set arrow from 2799, graph 0 to 2799, graph 1 nohead; set label "Mg II" at 2804, graph 0.8 } 
if(1908 > (A_min/(1.699+1)+20) && 1908 < (A_max/(1.699+1)-20)){set arrow from 1908, graph 0 to 1908, graph 1 nohead; set label "C III" at 1913, graph 0.8 } 
if(1549 > (A_min/(1.699+1)+20) && 1549 < (A_max/(1.699+1)-20)){set arrow from 1549, graph 0 to 1549, graph 1 nohead; set label "C IV" at 1554, graph 0.8 } 
if(1240 > (A_min/(1.699+1)+20) && 1240 < (A_max/(1.699+1)-20)){set arrow from 1240, graph 0 to 1240, graph 1 nohead; set label "N V" at 1245, graph 0.8 } 
if(6562 > (A_min/(1.699+1)+20) && 6562 < (A_max/(1.699+1)-20)){set arrow from 6562, graph 0 to 6562, graph 1 nohead; set label "H{/symbol a}" at 6567, graph 0.8 enhanced } 
if(4861 > (A_min/(1.699+1)+20) && 4861 < (A_max/(1.699+1)-20)){set arrow from 4861, graph 0 to 4861, graph 1 nohead; set label "H{/symbol b}" at 4866, graph 0.8 enhanced } 
if(4959 > (A_min/(1.699+1)+20) && 4959 < (A_max/(1.699+1)-20)){set arrow from 4959, graph 0 to 4959, graph 1 nohead; set label "O III" at 4964, graph 0.8 } 
if(5007 > (A_min/(1.699+1)+20) && 5007 < (A_max/(1.699+1)-20)){set arrow from 5007, graph 0 to 5007, graph 1 nohead; set label "O III" at 5012, graph 0.8 } 
if(4340 > (A_min/(1.699+1)+20) && 4340 < (A_max/(1.699+1)-20)){set arrow from 4340, graph 0 to 4340, graph 1 nohead; set label "H{/symbol g}" at 4345, graph 0.8 enhanced } 
if(1216 > (A_min/(1.699+1)+20) && 1216 < (A_max/(1.699+1)-20)){set arrow from 1216, graph 0 to 1216, graph 1 nohead; set label "L{/symbol a}" at 1221, graph 0.88 enhanced } 

は、なぜこれが正しく、誰このまたはエラーが表示さを改善するアイデアを動作しないのか? ありがとうございました!

+0

ラベルとそのxの位置をデータファイルに入れ、 'ラベル付き'と 'ベクトル付き'をプロットしてください – Christoph

答えて

0

gnuplotでif文を使用するのはよくわかりません。遠くに何かする必要があるとき、私は三項演算子を使いました。

(Amin+20 < 1200 && Amax-20 > 1200) ? {set label 'blabla'} :\ 
(Amin+20 < 1500 && Amax-20 > 1500) ? {set label 'blibla'} :\ 
... 
(Amin+20 < 1800 && Amax-20 > 1800) ? {set label 'blubla'} : 1/0 

また、私はこれらをplotステートメントの前に追加しますが、問題ではないかもしれません。 A_minが非常に小さく、A_maxが非常に大きい場合、あなたの声明でそれらの多くが同時に真実かもしれないと思います。三項構文解析では、最初の真の文が評価されます(if-elseif構文によく似ています)。

このスクリプトを使用している環境によっては、ラベルがsetになり、決してunsetを取得しないことがあります。このようにして、ステートメントが真になるとすぐに、それはセッションの残りの部分とそれに続くすべてのプロットに当てはまります。だから、スクリプトの先頭に

unset label 
unset arrow 

を追加してみてください。

+0

ありがとうございました!私もこれを試みます。 – Kupferhans

0

2つのコマンドset arrowset labelは、図をどこにでも飾るためのものであるため、プロット領域を尊重しません。

ラベルとその位置をデータファイルに置き、それをプロットします。

2799 "Mg II" 
1908 "C III" 
1549 "C IV" 
1240 "N V" 
6562 "H{/symbol a}" 
4861 "H{/symbol b}" 
4959 "O III" 
5007 "O III" 
4340 "H{/symbol g}" 
1216 "L{/symbol a}" 

でファイルlabels.txtを作成し、次にあなたがplotため座標を使用することはできませんので、あなたは問題ではありません同等の値を、計算しなければならない

reset 
stats '170.txt' using 2 name "Fluss" nooutput 
stats '170.txt' using 1 Name "A" nooutput 

x(v) = v/(1.699+1) 
ymin = -0.5 
ymax = Fluss_mean*3 
ylbl = ymin + 0.8 * (ymax - ymin) 

set yrange [ymin:ymax] 
set xrange [x(A_min):x(A_max)] 

plot '170.txt' u (x($1)):2 with lines, \ 
    'labels.txt` u 1:(ylbl):2 with labels enhanced t '',\ 
    '' u 1:(ymin):(0):(ymax - ymin) with vectors nohead t '' 

でそれをプロットとにかくstatsを使用しているからです。

+0

ありがとうございます!私はこれを試してみよう! – Kupferhans

+0

こんにちは、それはうまく動作しますが、ライン位置がレシートフレーム内の変換セットではないという問題があります。私は何かを変えなければならないのですか?(y1):(y1):(y1) 。 – Kupferhans

+0

usingステートメントの4つの列は 'x'、' y'、 'dx'、' dy'です。 'vectors'プロットスタイルのドキュメントを見てください。 'x($ 1)'は前に定義された関数 'x(v)'を使って最初の列の値を変換します。私は彼らがあなたのデータファイル '170.txt'の値と一致すると仮定しました。 '(ymin)'は変数 'ymin'の定数値、'(0) 'は数値ゼロです。 – Christoph

関連する問題