Created
October 17, 2019 15:50
-
-
Save austinmcconnell/353ce39fedea5d8e5a9ab9dcc22c3742 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