我想展示阈值对FAR和FRR(基本上是x范围有界时曲线下的区域)的影响。为此,我需要做这样的事情!
如果阈值移动,则由末端和阈值界定的相应区域也将移动。
我还希望两个相应的区域具有不同的颜色。有没有办法在octave / python /任何其他工具中做到这一点。最简单的方法是什么?
还有教科书作者如何绘制此类图形。当然,这些不是标准功能。
最佳答案
在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)
在这里,alpha用于创建透明度并在相交区域中组合两种颜色。您也可以使用其他颜色为该区域着色:
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')
如果只需要图形的底部(即阈值前后的功能区),这也很容易。让我们将绘图中的阈值定义为
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)
关于graph - 如何在 Octave 音阶下的函数下阴影区域?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13445168/