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

Skip to content

Commit f0afe77

Browse files
committed
DOC: explain changes to boxplot styles
1 parent 0a19616 commit f0afe77

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

doc/users/dflt_style_changes.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,73 @@ 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+
fig, (old, new) = pyplot.subplots(ncols=2, sharey=True)
426+
with pyplot.style.context('default'):
427+
new.boxplot(data, labels=['A', 'B', 'C', 'D'])
428+
new.set_title('New boxplots')
429+
430+
with pyplot.style.context('classic'):
431+
old.boxplot(data, labels=['A', 'B', 'C', 'D'])
432+
old.set_title('Old boxplots')
433+
434+
new.set_ylim(bottom=0)
435+
436+
The previous defaults can be restored by setting::
437+
438+
mpl.rcParams['boxplot.flierprops.color'] = 'k'
439+
mpl.rcParams['boxplot.flierprops.marker'] = '+'
440+
mpl.rcParams['boxplot.flierprops.markerfacecolor'] = 'none'
441+
mpl.rcParams['boxplot.flierprops.markeredgecolor'] = 'k'
442+
mpl.rcParams['boxplot.boxprops.color'] = 'b'
443+
mpl.rcParams['boxplot.whiskerprops.color'] = 'b'
444+
mpl.rcParams['boxplot.whiskerprops.linestyle'] = '--'
445+
mpl.rcParams['boxplot.medianprops.color'] = 'r'
446+
mpl.rcParams['boxplot.meanprops.color'] = 'r'
447+
mpl.rcParams['boxplot.meanprops.marker'] = '^'
448+
mpl.rcParams['boxplot.meanprops.markerfacecolor'] = 'r'
449+
mpl.rcParams['boxplot.meanprops.markeredgecolor'] = 'k'
450+
mpl.rcParams['boxplot.meanprops.markersize'] = 6
451+
mpl.rcParams['boxplot.meanprops.linestyle'] = '--'
452+
mpl.rcParams['boxplot.meanprops.linewidth'] = 1.0
453+
454+
or by setting::
455+
456+
boxplot.flierprops.color: 'k'
457+
boxplot.flierprops.marker: '+'
458+
boxplot.flierprops.markerfacecolor: 'none'
459+
boxplot.flierprops.markeredgecolor: 'k'
460+
boxplot.boxprops.color: 'b'
461+
boxplot.whiskerprops.color: 'b'
462+
boxplot.whiskerprops.linestyle: '--'
463+
boxplot.medianprops.color: 'r'
464+
boxplot.meanprops.color: 'r'
465+
boxplot.meanprops.marker: '^'
466+
boxplot.meanprops.markerfacecolor: 'r'
467+
boxplot.meanprops.markeredgecolor: 'k'
468+
boxplot.meanprops.markersize: 6
469+
boxplot.meanprops.linestyle: '--'
470+
boxplot.meanprops.linewidth: 1.0
471+
472+
in your :file:`matplotlibrc` file.
473+
474+
408475
Patch edges and color
409476
---------------------
410477

0 commit comments

Comments
 (0)