您的位置:首页 > 编程语言 > Python开发

Python 中利用 matplotlib 进行曲线的部分填充 fill_betweenx

2015-11-20 19:55 876 查看
Python 中利用 matplotlib 进行曲线的部分填充 fill_betweenx

实现效果:



代码:

def Plot_LSH_Curve(b, r, Sim_T):
s = np.arange(0, 1, 0.01)
p = 1 - np.power(1 - np.power(s, r), b)

fig = plt.figure()
ax = plt.gca()
# ax = fig.add_subplot(111)
ax.plot(s, p, color='red', linewidth=2)
plt.vlines(Sim_T, [0], 1, color="green", linewidth=3, linestyles="dashed")
ax.fill_betweenx(p, Sim_T, s, facecolor="orange", color="white")
ax.fill_betweenx(p, Sim_T, s, where=s >= Sim_T, facecolor='blue', color="white")
ax.set_title('S-curve of LSH')
ax.annotate('T', xy=(1.03*Sim_T, 0.45))
plt.grid()
plt.savefig('LSH_Scurve.png')
# plt.show()


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: