2

FAR と FRR に対するしきい値の影響を示したいと思います (基本的には、x 範囲が制限されている場合の曲線の下の領域)。そのためには、このようなことをする必要があります!

グラフ詐欺師と真の試み

しきい値が移動すると、両端としきい値によって囲まれた対応する領域も移動します。また、2 つの対応する領域を異なる色にしたいと考えています。オクターブ/python/その他のツールでそれを行う方法はありますか? そうする最も簡単な方法は何ですか?

また、教科書の著者がこの種のグラフを描く方法。これらは確かに標準機能ではありません。

4

2 に答える 2

5

Octave では、これは実際には非常に簡単です。他の例 (Octave 用に変換) に同じコードを使用します。

## create same fake data as other example
x = 0:0.1:20;
y1 = exp(-(x-6).**2 / 5);
y2 = 2 * exp(-(x-12).**2 / 8);

area (x, y1, "FaceColor", "blue");
hold on;
area (x, y2, "FaceColor", "red");
area (x, min ([y1; y2]), "FaceColor", "green");
hold off

次の図を取得します面積プロット

領域の透明度を で変更できるはずですがFaceAlpha、どうやらそれは Octave ではまだ実装されていません (ただし、いつか)。それまでの間、回避策として RGB 値を渡すことができます

area (x, y1,             "FaceColor", [0.0  0.0  0.8]);
hold on;
area (x, y2,             "FaceColor", [0.0  0.8  0.0]);
area (x, min ([y1; y2]), "FaceColor", [0.0  0.8  0.8]);
hold off
于 2012-11-22T17:15:42.553 に答える
5

Python では、matplotlib のfill_betweenを使用できます。

import numpy as np
import matplotlib.pyplot as plt

# Create some fake data
x = np.arange(0, 20, 0.01)
y1 = np.exp(-(x - 6)**2 / 5.)
y2 = 2 * np.exp(-(x - 12)**2 / 8.)

plt.plot(x, y1, 'r-')
plt.plot(x, y2, 'g-')
plt.fill_between(x, 0, y1, color='r', alpha=0.6)
plt.fill_between(x, 0, y2, color='g', alpha=0.6)

ディストリビューション

ここでは、アルファを使用して透明度を作成し、交差領域で 2 つの色を組み合わせています。その領域を別の色で着色することもできます。

idx_intsec = 828
plt.fill_between(x[:idx_intsec], 0, y2[:idx_intsec], color='y')
plt.fill_between(x[idx_intsec:], 0, y1[idx_intsec:], color='y')

distributions_yellow

グラフィックの下部 (つまり、しきい値の前後の機能領域) のみが必要な場合も簡単です。私のプロットのしきい値をx = 7次のように定義しましょう。

thres = 7.
idx_thres = np.argmin(np.abs(x - thres))
plt.plot(x[:idx_thres], y2[:idx_thres], 'g-')
plt.plot(x[idx_thres:], y1[idx_thres:], 'r-')
plt.plot([thres, thres], [0, y1[idx_thres]], 'r-')
plt.fill_between(x[:idx_thres], y2[:idx_thres], color='g', alpha=0.6)
plt.fill_between(x[idx_thres:], y1[idx_thres:], color='r', alpha=0.6)

distributions_small

于 2012-11-19T04:32:21.123 に答える