Created
October 17, 2019 15:50
-
-
Save austinmcconnell/afde8b8146d437a0530758b3fc7bf5c8 to your computer and use it in GitHub Desktop.
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 label_datapoints(axes, percent=False): | |
if percent: | |
precision = 2 | |
extra = '%' | |
else: | |
precision = 0 | |
extra = '' | |
for patch in axes.patches: | |
axes.text(x=patch.get_x() + patch.get_width() / 2., | |
y=patch.get_height(), | |
s='{:.{prec}f}{extra}'.format(float(patch.get_height()), | |
prec=precision, | |
extra=extra), | |
fontsize=14, | |
color='black', | |
ha='center', | |
va='bottom') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment