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?

3
  • should be simple enough to modify the code here for a horizontal bar chart: stackoverflow.com/questions/28931224/… Commented Jun 11, 2021 at 11:40
  • alternatively, see the ax.bar_label() function here: matplotlib.org/stable/api/_as_gen/… Commented Jun 11, 2021 at 11:41
  • for c in ax.containers: ax.bar_label(c, label_type='edge'); ax.margins(x=0.12) from the duplicate. Commented Jun 11, 2021 at 19:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.