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

Skip to content

Commit 2e975ac

Browse files
committed
fix whats_new doc
1 parent e98d59a commit 2e975ac

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

doc/users/next_whats_new/boxplot_legend_support.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ boxplot call:
3333
for patch, color in zip(bplot['boxes'], colors):
3434
patch.set_facecolor(color)
3535

36+
ax.set_xticks([])
3637
ax.legend()
3738

3839

@@ -43,16 +44,18 @@ patch artist will get its legend handle from the median line:
4344
:include-source: true
4445
:alt: Example of creating 2 boxplots and assigning each legend label as a string.
4546

47+
import matplotlib.pyplot as plt
48+
import numpy as np
49+
4650
fig, ax = plt.subplots()
51+
4752
data_A = np.random.random((100, 3))
4853
data_B = np.random.random((100, 3)) + 0.2
4954
pos = np.arange(3)
5055

51-
bplot2 = ax.boxplot(data_A, positions=pos - 0.2, label='Box A')
52-
bplot3 = ax.boxplot(data_B, positions=pos + 0.2, patch_artist=True, label='Box B')
53-
54-
# fill with colors
55-
for patch in bplot3['boxes']:
56-
patch.set_facecolor('lightblue')
56+
ax.boxplot(data_A, positions=pos - 0.2, patch_artist=True, label='Box A',
57+
boxprops={'facecolor': 'steelblue'})
58+
ax.boxplot(data_B, positions=pos + 0.2, patch_artist=True, label='Box B',
59+
boxprops={'facecolor': 'lightblue'})
5760

5861
ax.legend()

0 commit comments

Comments
 (0)