【发布时间】:2021-02-03 18:54:24
【问题描述】:
我试图让阴影颜色在 y=7.5 栏处停止,但绿色的颜色还不够远(即到线)。有人能解决这个问题吗?非常感谢!
# sensitivity analysis
sensitivity = pd.DataFrame()
for x in exit_probabilities:
for y in exit_valuations:
sensitivity.loc[y, x] = vc_valuation_method_mod(0.15, 5,x, y, 0.5, 5, 10, 6, 100, 80, 2.5)[0]
print(sensitivity)
#Plot data
sns.set(font_scale = 1.5, style = 'white', rc=None)
fig, ax = plt.subplots(figsize = (15,10))
a = sensitivity.plot(y = 0.2, ax = ax, linestyle = '--', color = 'gray')
b = sensitivity.plot(y = 0.3, ax = ax, linestyle = '-.', color = 'gray')
c = sensitivity.plot(y = 0.4, ax = ax, linestyle = ':', color = 'gray')
d = ax.hlines(y=7.5, xmin=100, xmax=900, colors='black', linestyles='-', lw=2, label='Single Short Line')
#ax.fill_between(a, d, alpha=2)
# fill between y=0.75 and df.y
# Adds headers
sensitivity.columns =['.1', '.15','.2','.25','.3','.35','.4']
ax.fill_between(x=sensitivity.index, y1=sensitivity['.2'], y2=7.5, where=sensitivity['.2'] > 7.5, interpolate=True)
ax.fill_between(x=sensitivity.index, y1=sensitivity['.3'], y2=np.maximum(sensitivity['.2'], 7.5),
where=sensitivity['.3'] > 7.5, interpolate=True)
ax.fill_between(x=sensitivity.index, y1=sensitivity['.4'], y2=np.maximum(sensitivity['.3'], 7.5),
where=sensitivity['.4'] > 7.5, interpolate=True)
plt.show()
sns.despine();
【问题讨论】:
标签: python python-3.x numpy matplotlib plot