I've been trying to figure out how to add statistical significance bars to specific subplots. Most related questions have been specific to a single plot, but does not show how to arbitrarily add statistical annotations to a subplot. Can someone show me how to add similar statistical annotations that are shown in the 4th subplot to each of the other subplots?
Here's the code and output that I get:
zero.columns= ['Number of Research Years', 'Total Publications', 'Publications During Residency',
'Publications Before & After Residency', 'H Index']
fig, axes = plt.subplots(2, 2, sharex= False, sharey= True, figsize=(8,8))
ax1= sns.barplot(ax=axes[0,0], x= zero['Number of Research Years'], y= zero['Total Publications'])
ax2= sns.barplot(ax=axes[0,1], x= zero['Number of Research Years'], y= zero['Publications During Residency'])
ax3= sns.barplot(ax=axes[1,0], x= zero['Number of Research Years'], y= zero['Publications Before & After Residency'])
ax4= sns.barplot(ax=axes[1,1], x= zero['Number of Research Years'], y= zero['H Index'])
x1, x2 = 1, 2
y, h, col = 100, 5, 'k'
plt.plot([x1, x1, x2, x2], [y, y+h, y+h, y], lw=1.5, c=col)
plt.text((x1+x2)*.5, y+h, "*", ha='center', va='bottom', color=col)
x1, x2 = 0, 2
y, h, col = 120, 5, 'k'
plt.plot([x1, x1, x2, x2], [y, y+h, y+h, y], lw=1.5, c=col)
plt.text((x1+x2)*.5, y+h, "*", ha='center', va='bottom', color=col)
ax1.text(0.05, 0.95, "A", fontweight="bold", transform=ax1.transAxes)
ax2.text(0.05, 0.95, "B", fontweight="bold", transform=ax2.transAxes)
ax3.text(0.05, 0.95, "C", fontweight="bold", transform=ax3.transAxes)
ax4.text(0.05, 0.95, "D", fontweight="bold", transform=ax4.transAxes)
sns.despine()
plt.show()