I want to create a Contour-Enhanced funnel plot (not a funnel chart),to test the small-study effect in meta-analysis like the following:
The above plot was created in R, which has several packages for doing this. However, I want to create it in Python, using matplotlib and pandas. How can I do this?
I have tried Pythonmeta package and got this funnel plot
This is the source code of the package:
def __init__(self,size=[6,6],dpi=80): #set figure
self.size=size #inchs
self.dpi=dpi #default:80pts
self.title="Meta-analysis Results "
self.nototal=False
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
logger.info("Load Fig().")
def funnel (self,effs):
myfig = Fig_Funnel (self.size,self.dpi,effs)
return myfig```
def Fig_Funnel (size,dpi,effs):
myfig = plt.figure(linewidth=1,figsize=size,dpi=dpi)
myfig.set_size_inches(size)
x=[];y=[]
for i in range(1,len(effs)):
x.append(effs[i][1])
y.append(effs[i][6])
lbl,=plt.plot(x,y,"o", lw=1)
ymax=max(y)+0.2
plt.ylim(ymax,0)
plt.plot([effs[0][1],effs[0][1]],[0,ymax],color="blue", linestyle="--",
lw=1)
plt.plot([effs[0][1],effs[0][1]-1.96*ymax],[0,ymax],color="blue",
linestyle="--", lw=1)
plt.plot([effs[0][1],effs[0][1]+1.96*ymax],[0,ymax],color="blue",
linestyle="--", lw=1)
ax = gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.xlabel("Effect Size")
plt.ylabel("Standard Error")
myfig.tight_layout()
return myfig