Created
August 20, 2020 06:11
-
-
Save RicherMans/0e452824207ecfe98f46a1c07863571e to your computer and use it in GitHub Desktop.
Plot values on bars in sns. Found online.
This file contains hidden or 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 show_values_on_bars(axs): | |
def _show_on_single_plot(ax): | |
for p in ax.patches: | |
_x = p.get_x() + p.get_width() / 2 | |
_y = p.get_y() + p.get_height() | |
value = '{:.0f}'.format(p.get_height()) | |
ax.text(_x, _y, value, ha="center",fontsize=10) | |
if isinstance(axs, np.ndarray): | |
for idx, ax in np.ndenumerate(axs): | |
_show_on_single_plot(ax) | |
else: | |
_show_on_single_plot(axs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment