2017-03-23 91 views
1

我在網上搜索了很長時間。但沒用。請幫助或嘗試提供一些想法如何實現這一點。如何在gnuplot中填充矩形函數下面的顏色?

我想繪製一維薛定諤方程的有限勢阱,所以我先建立逐步矩形函數,然後用'下面的實心曲線'繪製它。這是我的代碼:

Terminal type set to 'aqua' 
gnuplot> set style fill transparent solid 0.5 noborder 
gnuplot> set xrange [0:5] 
gnuplot> set yrange [0:0.8] 
gnuplot> p(x) = x<= 2? 0.5: x>= 3? 0.5: 0 
gnuplot> plot p(x) w filledcurves below lc rgb "gray" 
gnuplot> set samples 500 
gnuplot> replot 

我想在下面0.5的區域[0:2] & [3:5]均填充有灰色的顏色,並沒有顏色(2,3)怎麼我設置值爲0.

這裏是我得到的情節,但是,這不是我期待的結果。

image

我會比感謝你提供的任何想法更多。十分感謝!

+0

工作正常,我(與5.0.5,5.0.0,4.6.6測試),看到的是https: //i.stack.imgur.com/w5cGR.png – Christoph

+0

嗨克里斯托夫,我想填充的區域是x = 0:2和2:3因爲我爲這兩個區域設置了y = 0.5 –

+0

或者我理解以錯誤的方式命令?我覺得'gnuplot> p(x)= x <= 2? 0.5: x> = 3? 0.5:0'表示當x <= 2 or x> = 3時,y = 0.5,否則y = 0 –

回答

0

繪圖with filledcurves below不會做你所需要的。你必須給一個explicite參考x1軸,以獲得期望的結果:

set style fill transparent solid 0.5 noborder 
set xrange [0:5] 
set yrange [0:0.8] 
p(x) = x<= 2? 0.5: x>= 3? 0.5: 0 
set samples 500 
plot p(x) w filledcurves below x1 lc rgb "gray" 

enter image description here

+0

感謝您的回覆!我輸入了相同的行,但仍然有些奇怪。我的結果只有右手邊的部分看起來像你的,而左邊的部分看起來和以前一樣。這是版本的問題嗎?我正在使用5.0.5 –

+0

你可以嘗試不同的終端(wxt或qt)嗎?我沒有水上終端。答案中的圖像是用qt生成的。 – Christoph

+0

我其實沒有wxt或qt,但改變終端確實解決了問題!非常感謝! :d –

相關問題