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

Skip to content

Commit c4eb5e2

Browse files
authored
Merge pull request #17 from phobson/doc_v2_rel_notes2
DOC: explain changes to boxplot styles
2 parents 09ea01a + 6a18c66 commit c4eb5e2

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

doc/users/dflt_style_changes.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,74 @@ or by setting ::
405405
in your :file:`matplotlibrc` file.
406406

407407

408+
``boxplot``
409+
-----------
410+
411+
Previously, boxplots were composed of a mish-mash styles that were, for
412+
better for worse, inherited from Matlab. Most of the elements were blue,
413+
but the medians were red. The fliers (outliers) were black plus-symbols
414+
(`+`) and the whiskers were dashed lines, which created ambiguity if
415+
the (solid and black) caps were not drawn.
416+
417+
For the new defaults, everything is black except for the median and mean
418+
lines (if drawn), which are set to the first two elements of the current
419+
color cycle. Also, the default flier markers are now hollow circles,
420+
which maintain the ability of the plus-symbols to overlap without
421+
obscuring data too much.
422+
423+
.. plot::
424+
425+
data = np.random.lognormal(size=(37, 4))
426+
fig, (old, new) = plt.subplots(ncols=2, sharey=True)
427+
with plt.style.context('default'):
428+
new.boxplot(data, labels=['A', 'B', 'C', 'D'])
429+
new.set_title('New boxplots')
430+
431+
with plt.style.context('classic'):
432+
old.boxplot(data, labels=['A', 'B', 'C', 'D'])
433+
old.set_title('Old boxplots')
434+
435+
new.set_ylim(bottom=0)
436+
437+
The previous defaults can be restored by setting::
438+
439+
mpl.rcParams['boxplot.flierprops.color'] = 'k'
440+
mpl.rcParams['boxplot.flierprops.marker'] = '+'
441+
mpl.rcParams['boxplot.flierprops.markerfacecolor'] = 'none'
442+
mpl.rcParams['boxplot.flierprops.markeredgecolor'] = 'k'
443+
mpl.rcParams['boxplot.boxprops.color'] = 'b'
444+
mpl.rcParams['boxplot.whiskerprops.color'] = 'b'
445+
mpl.rcParams['boxplot.whiskerprops.linestyle'] = '--'
446+
mpl.rcParams['boxplot.medianprops.color'] = 'r'
447+
mpl.rcParams['boxplot.meanprops.color'] = 'r'
448+
mpl.rcParams['boxplot.meanprops.marker'] = '^'
449+
mpl.rcParams['boxplot.meanprops.markerfacecolor'] = 'r'
450+
mpl.rcParams['boxplot.meanprops.markeredgecolor'] = 'k'
451+
mpl.rcParams['boxplot.meanprops.markersize'] = 6
452+
mpl.rcParams['boxplot.meanprops.linestyle'] = '--'
453+
mpl.rcParams['boxplot.meanprops.linewidth'] = 1.0
454+
455+
or by setting::
456+
457+
boxplot.flierprops.color: 'k'
458+
boxplot.flierprops.marker: '+'
459+
boxplot.flierprops.markerfacecolor: 'none'
460+
boxplot.flierprops.markeredgecolor: 'k'
461+
boxplot.boxprops.color: 'b'
462+
boxplot.whiskerprops.color: 'b'
463+
boxplot.whiskerprops.linestyle: '--'
464+
boxplot.medianprops.color: 'r'
465+
boxplot.meanprops.color: 'r'
466+
boxplot.meanprops.marker: '^'
467+
boxplot.meanprops.markerfacecolor: 'r'
468+
boxplot.meanprops.markeredgecolor: 'k'
469+
boxplot.meanprops.markersize: 6
470+
boxplot.meanprops.linestyle: '--'
471+
boxplot.meanprops.linewidth: 1.0
472+
473+
in your :file:`matplotlibrc` file.
474+
475+
408476
Patch edges and color
409477
---------------------
410478

0 commit comments

Comments
 (0)