0

I want to show my values in hbar diagram but somehow I'm not able to render the values right to the bars.

Here is my code:

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd


index = ['average', '50th', '95th', '99.9th', 'max']
aaa = [3180, 2153, 9172, 9368, 9432]
bbb = [3857, 3367, 11638, 14555, 14731]
ccc = [740, 716, 1326, 1927, 2591]

df = pd.DataFrame({'aaa': aaa, 'bbb': bbb, 'ccc': ccc}, index=index)

ax = df.plot.barh()

enter image description here

How can I display my values to each bar and is also possible to save the figure for e.g. .png file?

imalik8088
  • 1,501
  • 5
  • 21
  • 39
  • should be simple enough to modify the code here for a horizontal bar chart: https://stackoverflow.com/questions/28931224/adding-value-labels-on-a-matplotlib-bar-chart – tmdavison Jun 11 '21 at 11:40
  • alternatively, see the `ax.bar_label()` function here: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.bar_label.html#matplotlib.axes.Axes.bar_label – tmdavison Jun 11 '21 at 11:41
  • `for c in ax.containers: ax.bar_label(c, label_type='edge'); ax.margins(x=0.12)` from the duplicate. – Trenton McKinney Jun 11 '21 at 19:31

0 Answers0