Skip to content

Instantly share code, notes, and snippets.

@RicherMans
Created August 20, 2020 06:11
Show Gist options
  • Save RicherMans/0e452824207ecfe98f46a1c07863571e to your computer and use it in GitHub Desktop.
Save RicherMans/0e452824207ecfe98f46a1c07863571e to your computer and use it in GitHub Desktop.
Plot values on bars in sns. Found online.
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