Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5dce348

Browse files
committed
Merge pull request #2447 from phobson/bug-boxplots-with-manual-CIarray
BUG: Fix boxplots with manual confidence intervals passed as a numpy array
2 parents 4b8ec14 + 3a97057 commit 5dce348

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/matplotlib/axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5990,7 +5990,7 @@ def computeConfInterval(data, med, iq, bootstrap):
59905990
raise ValueError(msg1)
59915991
elif conf_intervals.shape[0] != col:
59925992
raise ValueError(msg2)
5993-
elif conf_intervals.shape[1] == 2:
5993+
elif conf_intervals.shape[1] != 2:
59945994
raise ValueError(msg3)
59955995
else:
59965996
if len(conf_intervals) != col:

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,21 @@ def test_boxplot():
985985
conf_intervals=[None, (-1.0, 3.5)], notch=1)
986986
ax.set_ylim((-30, 30))
987987

988+
@image_comparison(baseline_images=['boxplot_with_CIarray'],
989+
remove_text=True, extensions=['png'],
990+
savefig_kwarg={'dpi': 40})
991+
def test_boxplot_with_CIarray():
992+
x = np.linspace(-7, 7, 140)
993+
x = np.hstack([-25, x, 25])
994+
fig = plt.figure()
995+
ax = fig.add_subplot(111)
996+
CIs = np.array([[-1.5, 3.], [-1., 3.5]])
997+
998+
# show 1 boxplot with mpl medians/conf. interfals, 1 with manual values
999+
ax.boxplot([x, x], bootstrap=10000, usermedians=[None, 1.0],
1000+
conf_intervals=CIs, notch=1)
1001+
ax.set_ylim((-30, 30))
1002+
9881003
@image_comparison(baseline_images=['boxplot_no_inverted_whisker'],
9891004
remove_text=True, extensions=['png'],
9901005
savefig_kwarg={'dpi': 40})

0 commit comments

Comments
 (0)