3

ベジェスムーズでプロットしたい曲線を定義する一連のポイント「データ」があります。そのため、x 値のいくつかのペアの間の曲線の下の領域を塗りつぶしたいと考えています。x 値のペアが 1 つしかない場合は、新しいデータ セットを定義して fillcu でプロットするので、それほど難しくありません。例:

やりたいことの例

問題は、同じプロットでそれを数回実行したいということです。

編集:最小限の実例:

#!/usr/bin/gnuplot
set terminal wxt enhanced font 'Verdana,12'

set style fill transparent solid 0.35 noborder
plot 'data' using 1:2 smooth sbezier with lines ls 1
pause -1

「データ」の構造は次のとおりです。

x_point y_point

そして、私の問題は、実際には曲線を1つも塗りつぶすことができないことであることに気付きました。勾配がほぼ一定であるため、塗りつぶされているように見えます。

4

1 に答える 1

12

filledcurves曲線の下の部分を塗りつぶすには、スタイルを使用する必要があります。オプションx1を使用すると、曲線と x 軸の間の部分を塗りつぶします。

曲線の一部だけを埋めるには、データをフィルタリングする必要があります。つまり、x 値が1/0目的の範囲外にある場合は (無効なデータ ポイント) の値を与え、そうでない場合はデータ ファイルから正しい値を与えます。最後に、曲線自体をプロットします。

set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot 'data' using (filter($1, -1, -0.5)):2 with filledcurves x1 lt 1 notitle,\
     ''  using (filter($1, 0.2, 0.8)):2 with filledcurves x1 lt 1 notitle,\
     ''  using 1:2 with lines lw 3 lt 1 title 'curve'

[-1:0.5]これにより、との範囲が満たされます[0.2:0.8]

実際の例を示すために、特別な filename を使用します+

set samples 100
set xrange [-2:2]
f(x) = -x**2 + 4

set linetype 1 lc rgb '#A3001E'

set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot '+' using (filter($1, -1, -0.5)):(f($1)) with filledcurves x1 lt 1 notitle,\
     ''  using (filter($1, 0.2, 0.8)):(f($1)) with filledcurves x1 lt 1 notitle,\
     ''  using 1:(f($1)) with lines lw 3 lt 1 title 'curve'

結果 (4.6.4 の場合):

ここに画像の説明を入力

なんらかの平滑化を使用する必要がある場合は、フィルター処理された部分に応じて、フィルターがデータ曲線に異なる影響を与える可能性があります。最初に平滑化されたデータを一時ファイルに書き込んでから、これを「通常の」プロットに使用できます。

set table 'data-smoothed'
plot 'data' using 1:2 smooth bezier
unset table

set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot 'data-smoothed' using (filter($1, -1, -0.5)):2 with filledcurves x1 lt 1 notitle,\
     ''  using (filter($1, 0.2, 0.8)):2 with filledcurves x1 lt 1 notitle,\
     ''  using 1:2 with lines lw 3 lt 1 title 'curve'
于 2014-06-04T07:16:29.890 に答える