Created
June 11, 2013 23:57
-
-
Save nkrumm/5761870 to your computer and use it in GitHub Desktop.
Draw horizontal p-value comparison bars in barplots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def drawBars(ax, s, ypos, xpos = [0.5,1.5], tick_height = 0.02, fontsize=12, fontcolor="black"): | |
ypos = ypos/float(ax.get_ylim()[1]) + tick_height | |
trans = transforms.blended_transform_factory(ax.transData, ax.transAxes) | |
l = Line2D([xpos[0], xpos[0], xpos[1], xpos[1]],[ypos, ypos+tick_height, ypos+tick_height, ypos], lw=1.5, c="k", transform=trans) | |
ax.text(xpos[0] + ((xpos[1]-xpos[0])/2.), ypos + (tick_height*1.5), s=s, ha= "center", va="bottom", fontsize=fontsize, color=fontcolor, transform=trans) | |
ax.add_line(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment