I'm trying to create a barchart that keeps always a fixed distance between outer and inner position, regardless of the labels length. I would like to see bar and bar_long in the same position as bar_long and bar_perfect do. I've tried to work with axes.set_position(), but in vain. Thanks in advance for appreciated help!
import matplotlib.pyplot as plt
def createBar(figx, figy, labels):
fig, ax = plt.subplots(figsize=(figx, figy)
performance = [10, 70, 120]
ax.barh(labels, performance)
return fig
bar = createBar(2, 1, ('Tom', 'Dick', 'Fred'))
bar_long = createBar(2, 1, ('Tom Cruise', 'Dick & Doof', 'Fred Astaire'))
bar_perfect = createBar(2, 1, (' Tom', 'Dick', 'Fred'))