Skip to content

Commit f26a402

Browse files
committed
better shaping checking logic
1 parent 437f5c2 commit f26a402

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,25 +2937,26 @@ def boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
29372937

29382938
# replace medians if necessary:
29392939
if usermedians is not None:
2940-
if len(np.ravel(usermedians)) != len(bxpstats):
2940+
if (len(np.ravel(usermedians)) != len(bxpstats) and
2941+
np.shape(usermedians)[0] != len(bxpstats)):
29412942
medmsg = 'usermedians length not compatible with x'
29422943
raise ValueError(medmsg)
29432944
else:
2945+
# reassign medians as necessary
29442946
for stats, med in zip(bxpstats, usermedians):
29452947
if med is not None:
29462948
stats['med'] = med
29472949

29482950
if conf_intervals is not None:
2949-
if len(conf_intervals) != len(bxpstats):
2950-
cimsg = 'conf_intervals length not compatible with x'
2951-
raise ValueError(cimsg)
2951+
if np.shape(conf_intervals)[0] != len(bxpstats):
2952+
raise ValueError('conf_intervals length not '
2953+
'compatible with x')
29522954
else:
29532955
for stats, ci in zip(bxpstats, conf_intervals):
29542956
if ci is not None:
29552957
if len(ci) != 2:
2956-
cimsg2 = 'each confidence interval must '\
2957-
'have two values'
2958-
raise ValueError(cimsg2)
2958+
raise ValueError('each confidence interval must '
2959+
'have two values')
29592960
else:
29602961
if ci[0] is not None:
29612962
stats['cilo'] = ci[0]

0 commit comments

Comments
 (0)