Skip to content

Commit 6db8509

Browse files
committed
Add f-string option to fmt in bar_label().
1 parent 9b1fcf6 commit 6db8509

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
@@ -2745,7 +2745,13 @@ def sign(x):
27452745
if np.isnan(dat):
27462746
lbl = ''
27472747

2748-
annotation = self.annotate(fmt % value if lbl is None else lbl,
2748+
if lbl is None:
2749+
formatted_value = (
2750+
fmt.format(value) if fmt.startswith('{') else fmt % value
2751+
)
2752+
else:
2753+
formatted_value = lbl
2754+
annotation = self.annotate(formatted_value,
27492755
xy, xytext, textcoords="offset points",
27502756
ha=ha, va=va, **kwargs)
27512757
annotations.append(annotation)

0 commit comments

Comments
 (0)