Gnuplotのデータの曲線の下にいくつかのセクションを入力してください

StackOverflow https://stackoverflow.com//questions/24027903

  •  21-12-2019
  •  | 
  •  

質問

Bezier Smoothでプロットしたい曲線を定義する「データ」のセットを持っています。 そのため、X値のペアの間の曲線の下の領域を埋めます。 X値のペアを1組していた場合、新しいデータセットを定義してFILEDECUでプロットするので、それほど難しくありません。例:

私がやりたいものの例

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

編集:最小限の実施例:

#!/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曲線でも満たすことができないということであることに気づきました、勾配がほとんど一定であるため埋められるようです。

役に立ちましたか?

解決

カーブの下の部分を埋めるためには、filledcurvesスタイルを使用する必要があります。 Option 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]の範囲を埋めます。

実施例を与えるために、特別なファイル名+を使用します。

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):

ENTER IMENTDESCRUストレーション

何らかの平滑化を使用する必要がある場合、フィルタはフィルタリングされた部分によってはデータ曲線に異なる影響を与える可能性があります。まず平滑化されたデータを一時ファイルに書き込み、これを「通常」プロットに使用することができます。

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'
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top