Skip to content

Instantly share code, notes, and snippets.

@leelasd
Created July 6, 2015 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leelasd/fec73fd73fa269c75865 to your computer and use it in GitHub Desktop.
Save leelasd/fec73fd73fa269c75865 to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
%matplotlib inline
cm = plt.cm.get_cmap('rainbow')
df1=pd.read_csv('Dat.csv')
df2=pd.read_csv('Dat2.csv')
df=df1.append(df2)
df=df.sort(['RDF','SIG'])
df['ERR']=df.RDF - 2.40
fig,ax1 = plt.subplots()
ax2 = ax1.twinx()
for i in range(0,40):
llim=0.0+i*0.05
ulim=0.05+i*0.05
ndf=df[(df.ERR >= llim )&(df.ERR <= ulim)]
x=ndf.SIG
y=ndf.EPS
Y=np.log10(y)
if (len(Y)>2):
m,c,r,p,se1=stats.linregress(x,Y)
print i,llim,ulim,m,c,r**2
cm1lab="$"+('y=%2.2fx+%2.2f, r^2=%1.2f'%(m,c,r**2))+"$";
ax1.plot(x, m*x+c,c=cm(i*9),linewidth=2,label=cm1lab)
ax2.plot(x,y,'o',mfc='none',mec=cm(i*9),mew=1.2)
ax2.set_yscale('log')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment