Is there a way to get the height of each bar in a barplot in matplotlib in pixels? I can easily get values In a list but actually I need the height of the bars to be in pixels. My output should be the containing list of heights of each bar in pixels and a plot. Is it possible?
Here is reproducible example:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
langs = ['C', 'C++', 'Java', 'Python', 'PHP']
students = [23,17,35,29,12]
ax.bar(langs,students)
hth = []
for i in ax.patches:
hth.append(i.get_height())
print(hth)
plt.show()
Output [23, 17, 35, 29, 12]