Closed
Description
Bug summary
bar_label overlaps bars when the y-axis is inverted
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
labels = ['G1', 'G2', 'G3', 'G4', 'G5']
men_means = [20, 34, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
x = np.arange(len(labels)) # the label locations
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, men_means, width, label='Men')
rects2 = ax.bar(x + width/2, women_means, width, label='Women')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.legend()
ax.invert_yaxis()
ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)
fig.tight_layout()
plt.show()
Actual outcome
Expected outcome
The bar_label most be stay at the end of the bar without overlapping it, but with the y-axis inverted
Additional information
No response
Operating system
No response
Matplotlib Version
3.5.1
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels