I have a dataframe of values which I am using to plot a scatter/line graph with confidence intervals:
The dataframe (sqlDF2) is like this:
Statu Total count Success Pred Upper95 Lower95 Upper99 Lower99
Org
A 391 391 38 0.35064 0.398903 0.302377 0.423034 0.278245
B 360 360 30 0.343464 0.393519 0.293408 0.418546 0.268381
C 271 271 29 0.319606 0.37626 0.262951 0.404587 0.234624
D 247 247 22 0.312089 0.371053 0.253125 0.400535 0.223643
...
The code that I plot the graph is:
y = sqlDf2['Success'].values
x = sqlDf2['Total'].values
up95 = (sqlDf2['Upper95'].values)*100
low95 = (sqlDf2['Lower95'].values)*100
up99 = (sqlDf2['Upper99'].values)*100
low99 = (sqlDf2['Lower99'].values)*100
middleLine = (sqlDf2['Pred'].values)*100
plt.figure(figsize=(15,8))
plt.ylim(0, 100)
plt.margins(x=0)
plt.scatter(x,y,marker='o',c='white',edgecolors = 'black', alpha=.5)
plt.plot(x,up95, 'red', linestyle=':', dashes=(1, 5), linewidth=1)
plt.plot(x,low95, 'red', linestyle=':', dashes=(1, 5), linewidth=1)
plt.plot(x,up99, 'red', linestyle=':', dashes=(1, 5), linewidth=1)
plt.plot(x,low99, 'red', linestyle=':', dashes=(1, 5), linewidth=1)
plt.plot(x,middleLine, 'red', linestyle='-', dashes=(1, 2), linewidth=1)
plt.show()
The graph looks like this:
What I want to do is annotate the values that fall ABOVE and BELOW the 99% confidence intervals with the value of 'Org'. Is there a easy way to work out those values which fall above and below two lines in Python?
Thank you
