Skip to content

Commit d18d7d7

Browse files
committed
Implement solution from matplotlib#23688 to properly center bar labels with different scales.
1 parent 9b1fcf6 commit d18d7d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2712,7 +2712,13 @@ def sign(x):
27122712
value = extrema
27132713

27142714
if label_type == "center":
2715-
xy = xc, yc
2715+
xy = (0.5, 0.5)
2716+
kwargs["xycoords"] = (
2717+
lambda r, b=bar:
2718+
mtransforms.Bbox.intersection(
2719+
b.get_window_extent(r), b.get_clip_box()
2720+
)
2721+
)
27162722
else: # edge
27172723
if orientation == "vertical":
27182724
xy = xc, endpt

0 commit comments

Comments
 (0)