Skip to content

Instantly share code, notes, and snippets.

@nkrumm
Created June 11, 2013 23:57
Show Gist options
  • Save nkrumm/5761870 to your computer and use it in GitHub Desktop.
Save nkrumm/5761870 to your computer and use it in GitHub Desktop.
Draw horizontal p-value comparison bars in barplots
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