8000 DOC: better unit argument errors axes.bar · matplotlib/matplotlib@f2fca36 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit f2fca36

Browse files
committed
DOC: better unit argument errors axes.bar
1 parent 912eb07 commit f2fca36

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,10 +2274,20 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
22742274
# left, bottom, width, height vectors
22752275
if align == 'center':
22762276
if orientation == 'vertical':
2277-
left = x - width / 2
2277+
try:
2278+
left = x - width / 2
2279+
except TypeError as e:
2280+
raise TypeError(f'the dtypes of parameters x ({x.dtype}) '
2281+
f'and width ({width.dtype}) '
2282+
'are incompatible') from e
22782283
bottom = y
22792284
elif orientation == 'horizontal':
2280-
bottom = y - height / 2
2285+
try:
2286+
bottom = y - height / 2
2287+
except TypeError as e:
2288+
raise TypeError(f'the dtypes of parameters y ({y.dtype}) '
2289+
f'and height ({height.dtype}) '
2290+
'are incompatible') from e
22812291
left = x
22822292
elif align == 'edge':
22832293
left = x

0 commit comments

Comments
 (0)
0