From 973f7ace842f14b523ca449a6a6b8d30ac7fb61a Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 16 Mar 2019 18:34:08 +0100 Subject: [PATCH] Update seaborn style --- .../2019-03-17-TH-seaborn-style.rst | 8 ++ .../mpl-data/stylelib/seaborn-bright.mplstyle | 6 +- .../stylelib/seaborn-bright6.mplstyle | 3 + .../stylelib/seaborn-colorblind.mplstyle | 6 +- .../stylelib/seaborn-colorblind6.mplstyle | 3 + .../stylelib/seaborn-dark-palette.mplstyle | 4 +- .../mpl-data/stylelib/seaborn-dark.mplstyle | 43 ++++--- .../stylelib/seaborn-dark6-palette.mplstyle | 3 + .../stylelib/seaborn-darkgrid.mplstyle | 43 ++++--- .../mpl-data/stylelib/seaborn-deep.mplstyle | 4 +- .../mpl-data/stylelib/seaborn-deep6.mplstyle | 3 + .../mpl-data/stylelib/seaborn-muted.mplstyle | 6 +- .../mpl-data/stylelib/seaborn-muted6.mplstyle | 3 + .../stylelib/seaborn-notebook.mplstyle | 35 +++--- .../mpl-data/stylelib/seaborn-paper.mplstyle | 35 +++--- .../mpl-data/stylelib/seaborn-pastel.mplstyle | 6 +- .../stylelib/seaborn-pastel6.mplstyle | 3 + .../mpl-data/stylelib/seaborn-poster.mplstyle | 39 ++++--- .../mpl-data/stylelib/seaborn-talk.mplstyle | 39 ++++--- .../mpl-data/stylelib/seaborn-ticks.mplstyle | 43 ++++--- .../mpl-data/stylelib/seaborn-white.mplstyle | 43 ++++--- .../stylelib/seaborn-whitegrid.mplstyle | 43 ++++--- .../mpl-data/stylelib/seaborn.mplstyle | 105 +++++++++++------- lib/matplotlib/testing/conftest.py | 10 ++ lib/matplotlib/tests/conftest.py | 2 +- lib/matplotlib/tests/test_style.py | 93 ++++++++++++++++ requirements/testing/travis36.txt | 1 + 27 files changed, 424 insertions(+), 208 deletions(-) create mode 100644 doc/api/next_api_changes/2019-03-17-TH-seaborn-style.rst create mode 100644 lib/matplotlib/mpl-data/stylelib/seaborn-bright6.mplstyle create mode 100644 lib/matplotlib/mpl-data/stylelib/seaborn-colorblind6.mplstyle create mode 100644 lib/matplotlib/mpl-data/stylelib/seaborn-dark6-palette.mplstyle create mode 100644 lib/matplotlib/mpl-data/stylelib/seaborn-deep6.mplstyle create mode 100644 lib/matplotlib/mpl-data/stylelib/seaborn-muted6.mplstyle create mode 100644 lib/matplotlib/mpl-data/stylelib/seaborn-pastel6.mplstyle diff --git a/doc/api/next_api_changes/2019-03-17-TH-seaborn-style.rst b/doc/api/next_api_changes/2019-03-17-TH-seaborn-style.rst new file mode 100644 index 000000000000..dc3998a017cc --- /dev/null +++ b/doc/api/next_api_changes/2019-03-17-TH-seaborn-style.rst @@ -0,0 +1,8 @@ +API changes +``````````` + +The the style changes introduced in seaborn 0.9 have been included in the +Matplotlib seaborn styles. +Most notably, the color palettes have been extended from 6 to 10 colors. +The former 6-color palettes are still available via a '6' suffix in the +style name, e.g. ``plt.style.use('seaborn-bright6')``. diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-bright.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-bright.mplstyle index 5e9e94937815..a863f1941a8e 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-bright.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-bright.mplstyle @@ -1,3 +1,3 @@ -# Seaborn bright palette -axes.prop_cycle: cycler('color', ['003FFF', '03ED3A', 'E8000B', '8A2BE2', 'FFC400', '00D7FF']) -patch.facecolor: 003FFF +# seaborn bright palette +axes.prop_cycle: cycler('color', ['023EFF', 'FF7C00', '1AC938', 'E8000B', '8B2BE2', '9F4800', 'F14CC1', 'A3A3A3', 'FFC400', '00D7FF']) +patch.facecolor: 023EFF diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-bright6.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-bright6.mplstyle new file mode 100644 index 000000000000..bc571924480d --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-bright6.mplstyle @@ -0,0 +1,3 @@ +# seaborn bright6 palette +axes.prop_cycle: cycler('color', ['023EFF', '1AC938', 'E8000B', '8B2BE2', 'FFC400', '00D7FF']) +patch.facecolor: 023EFF diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind.mplstyle index e13b7aade323..8a30222d14e8 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind.mplstyle @@ -1,3 +1,3 @@ -# Seaborn colorblind palette -axes.prop_cycle: cycler('color', ['0072B2', '009E73', 'D55E00', 'CC79A7', 'F0E442', '56B4E9']) -patch.facecolor: 0072B2 +# seaborn colorblind palette +axes.prop_cycle: cycler('color', ['0173B2', 'DE8F05', '029E73', 'D55E00', 'CC78BC', 'CA9161', 'FBAFE4', '949494', 'ECE133', '56B4E9']) +patch.facecolor: 0173B2 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind6.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind6.mplstyle new file mode 100644 index 000000000000..421edfbabb33 --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-colorblind6.mplstyle @@ -0,0 +1,3 @@ +# seaborn colorblind6 palette +axes.prop_cycle: cycler('color', ['0173B2', '029E73', 'D55E00', 'CC78BC', 'ECE133', '56B4E9']) +patch.facecolor: 0173B2 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-dark-palette.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-dark-palette.mplstyle index 30160ae2506c..dd5051d7f12c 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-dark-palette.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-dark-palette.mplstyle @@ -1,3 +1,3 @@ -# Seaborn dark palette -axes.prop_cycle: cycler('color', ['001C7F', '017517', '8C0900', '7600A1', 'B8860B', '006374']) +# seaborn dark palette +axes.prop_cycle: cycler('color', ['001C7F', 'B1400D', '12711C', '8C0800', '591E71', '592F0D', 'A23582', '3C3C3C', 'B8850A', '006374']) patch.facecolor: 001C7F diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-dark.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-dark.mplstyle index 55b50b5bdd26..3c25c33956a6 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-dark.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-dark.mplstyle @@ -1,30 +1,41 @@ -# Seaborn common parameters -# .15 = dark_gray -# .8 = light_gray +# seaborn dark style + +# common parameters (see style_dict in seaborn.rcmod.axes_style()): figure.facecolor: white -text.color: .15 axes.labelcolor: .15 -legend.frameon: False -legend.numpoints: 1 -legend.scatterpoints: 1 + xtick.direction: out ytick.direction: out xtick.color: .15 ytick.color: .15 + axes.axisbelow: True -image.cmap: Greys -font.family: sans-serif -font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif grid.linestyle: - + +text.color: .15 +font.family: sans-serif +font.sans-serif: Arial, DejaVu Sans, Liberation Sans, Bitstream Vera Sans, sans-serif + lines.solid_capstyle: round +patch.edgecolor: w +patch.force_edgecolor: True + +# seaborn image.cmap is "rocket", but we do not have that +image.cmap: Greys -# Seaborn dark parameters +xtick.top: False +ytick.right: False + + +# dark parameters axes.grid: False axes.facecolor: EAEAF2 axes.edgecolor: white -axes.linewidth: 0 grid.color: white -xtick.major.size: 0 -ytick.major.size: 0 -xtick.minor.size: 0 -ytick.minor.size: 0 +axes.spines.left: True +axes.spines.bottom: True +axes.spines.right: True +axes.spines.top: True + +xtick.bottom: False +ytick.left: False diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-dark6-palette.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-dark6-palette.mplstyle new file mode 100644 index 000000000000..43325cfbb3ed --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-dark6-palette.mplstyle @@ -0,0 +1,3 @@ +# seaborn dark6 palette +axes.prop_cycle: cycler('color', ['001C7F', '12711C', '8C0800', '591E71', 'B8850A', '006374']) +patch.facecolor: 001C7F diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-darkgrid.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-darkgrid.mplstyle index 0f5d955d7df6..a1d15bb629d6 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-darkgrid.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-darkgrid.mplstyle @@ -1,30 +1,41 @@ -# Seaborn common parameters -# .15 = dark_gray -# .8 = light_gray +# seaborn darkgrid style + +# common parameters (see style_dict in seaborn.rcmod.axes_style()): figure.facecolor: white -text.color: .15 axes.labelcolor: .15 -legend.frameon: False -legend.numpoints: 1 -legend.scatterpoints: 1 + xtick.direction: out ytick.direction: out xtick.color: .15 ytick.color: .15 + axes.axisbelow: True -image.cmap: Greys -font.family: sans-serif -font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif grid.linestyle: - + +text.color: .15 +font.family: sans-serif +font.sans-serif: Arial, DejaVu Sans, Liberation Sans, Bitstream Vera Sans, sans-serif + lines.solid_capstyle: round +patch.edgecolor: w +patch.force_edgecolor: True + +# seaborn image.cmap is "rocket", but we do not have that +image.cmap: Greys -# Seaborn darkgrid parameters +xtick.top: False +ytick.right: False + + +# darkgrid parameters axes.grid: True axes.facecolor: EAEAF2 axes.edgecolor: white -axes.linewidth: 0 grid.color: white -xtick.major.size: 0 -ytick.major.size: 0 -xtick.minor.size: 0 -ytick.minor.size: 0 +axes.spines.left: True +axes.spines.bottom: True +axes.spines.right: True +axes.spines.top: True + +xtick.bottom: False +ytick.left: False diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-deep.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-deep.mplstyle index 5d6b7c560098..50b9e8b944b4 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-deep.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-deep.mplstyle @@ -1,3 +1,3 @@ -# Seaborn deep palette -axes.prop_cycle: cycler('color', ['4C72B0', '55A868', 'C44E52', '8172B2', 'CCB974', '64B5CD']) +# seaborn deep palette +axes.prop_cycle: cycler('color', ['4C72B0', 'DD8452', '55A868', 'C44E52', '8172B3', '937860', 'DA8BC3', '8C8C8C', 'CCB974', '64B5CD']) patch.facecolor: 4C72B0 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-deep6.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-deep6.mplstyle new file mode 100644 index 000000000000..59e4a2e981b2 --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-deep6.mplstyle @@ -0,0 +1,3 @@ +# seaborn deep6 palette +axes.prop_cycle: cycler('color', ['4C72B0', '55A868', 'C44E52', '8172B3', 'CCB974', '64B5CD']) +patch.facecolor: 4C72B0 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-muted.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-muted.mplstyle index 4a71646ce903..7c0dac983283 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-muted.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-muted.mplstyle @@ -1,3 +1,3 @@ -# Seaborn muted palette -axes.prop_cycle: cycler('color', ['4878CF', '6ACC65', 'D65F5F', 'B47CC7', 'C4AD66', '77BEDB']) -patch.facecolor: 4878CF +# seaborn muted palette +axes.prop_cycle: cycler('color', ['4878D0', 'EE854A', '6ACC64', 'D65F5F', '956CB4', '8C613C', 'DC7EC0', '797979', 'D5BB67', '82C6E2']) +patch.facecolor: 4878D0 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-muted6.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-muted6.mplstyle new file mode 100644 index 000000000000..8bfe398ad9ae --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-muted6.mplstyle @@ -0,0 +1,3 @@ +# seaborn muted6 palette +axes.prop_cycle: cycler('color', ['4878D0', '6ACC64', 'D65F5F', '956CB4', 'D5BB67', '82C6E2']) +patch.facecolor: 4878D0 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-notebook.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-notebook.mplstyle index 18bcf3e12042..8791dbd68282 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-notebook.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-notebook.mplstyle @@ -1,21 +1,24 @@ -# Seaborn notebook context -figure.figsize: 8.0, 5.5 -axes.labelsize: 11 +# seaborn notebook context +# see seaborn.rcmod.plotting_context() +font.size: 12 +axes.labelsize: 12 axes.titlesize: 12 -xtick.labelsize: 10 -ytick.labelsize: 10 -legend.fontsize: 10 +xtick.labelsize: 11 +ytick.labelsize: 11 +legend.fontsize: 11 +axes.linewidth: 1.25 grid.linewidth: 1 -lines.linewidth: 1.75 -patch.linewidth: .3 -lines.markersize: 7 -lines.markeredgewidth: 0 +lines.linewidth: 1.5 +lines.markersize: 6 +patch.linewidth: 1 -xtick.major.width: 1 -ytick.major.width: 1 -xtick.minor.width: .5 -ytick.minor.width: .5 +xtick.major.width: 1.25 +ytick.major.width: 1.25 +xtick.minor.width: 1 +ytick.minor.width: 1 -xtick.major.pad: 7 -ytick.major.pad: 7 +xtick.major.size: 6 +ytick.major.size: 6 +xtick.minor.size: 4 +ytick.minor.size: 4 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-paper.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-paper.mplstyle index 3326be4333b8..b47fc1e297ef 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-paper.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-paper.mplstyle @@ -1,21 +1,24 @@ -# Seaborn paper context -figure.figsize: 6.4, 4.4 -axes.labelsize: 8.8 +# seaborn paper context +# see seaborn.rcmod.plotting_context() +font.size: 9.6 +axes.labelsize: 9.6 axes.titlesize: 9.6 -xtick.labelsize: 8 -ytick.labelsize: 8 -legend.fontsize: 8 +xtick.labelsize: 8.8 +ytick.labelsize: 8.8 +legend.fontsize: 8.8 +axes.linewidth: 1 grid.linewidth: 0.8 -lines.linewidth: 1.4 -patch.linewidth: 0.24 -lines.markersize: 5.6 -lines.markeredgewidth: 0 +lines.linewidth: 1.2 +lines.markersize: 4.8 +patch.linewidth: 0.8 -xtick.major.width: 0.8 -ytick.major.width: 0.8 -xtick.minor.width: 0.4 -ytick.minor.width: 0.4 +xtick.major.width: 1 +ytick.major.width: 1 +xtick.minor.width: 0.8 +ytick.minor.width: 0.8 -xtick.major.pad: 5.6 -ytick.major.pad: 5.6 +xtick.major.size: 4.8 +ytick.major.size: 4.8 +xtick.minor.size: 3.2 +ytick.minor.size: 3.2 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-pastel.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-pastel.mplstyle index dff67482c085..3feb2ab1b3e9 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-pastel.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-pastel.mplstyle @@ -1,3 +1,3 @@ -# Seaborn pastel palette -axes.prop_cycle: cycler('color', ['92C6FF', '97F0AA', 'FF9F9A', 'D0BBFF', 'FFFEA3', 'B0E0E6']) -patch.facecolor: 92C6FF +# seaborn pastel palette +axes.prop_cycle: cycler('color', ['A1C9F4', 'FFB482', '8DE5A1', 'FF9F9B', 'D0BBFF', 'DEBB9B', 'FAB0E4', 'CFCFCF', 'FFFEA3', 'B9F2F0']) +patch.facecolor: A1C9F4 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-pastel6.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-pastel6.mplstyle new file mode 100644 index 000000000000..08277c582d1b --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-pastel6.mplstyle @@ -0,0 +1,3 @@ +# seaborn pastel6 palette +axes.prop_cycle: cycler('color', ['A1C9F4', '8DE5A1', 'FF9F9B', 'D0BBFF', 'FFFEA3', 'B9F2F0']) +patch.facecolor: A1C9F4 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-poster.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-poster.mplstyle index 47f237006cae..15ebcbadf534 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-poster.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-poster.mplstyle @@ -1,21 +1,24 @@ -# Seaborn poster context -figure.figsize: 12.8, 8.8 -axes.labelsize: 17.6 -axes.titlesize: 19.2 -xtick.labelsize: 16 -ytick.labelsize: 16 -legend.fontsize: 16 +# seaborn poster context +# see seaborn.rcmod.plotting_context() +font.size: 24 +axes.labelsize: 24 +axes.titlesize: 24 +xtick.labelsize: 22 +ytick.labelsize: 22 +legend.fontsize: 22 -grid.linewidth: 1.6 -lines.linewidth: 2.8 -patch.linewidth: 0.48 -lines.markersize: 11.2 -lines.markeredgewidth: 0 +axes.linewidth: 2.5 +grid.linewidth: 2 +lines.linewidth: 3 +lines.markersize: 12 +patch.linewidth: 2 -xtick.major.width: 1.6 -ytick.major.width: 1.6 -xtick.minor.width: 0.8 -ytick.minor.width: 0.8 +xtick.major.width: 2.5 +ytick.major.width: 2.5 +xtick.minor.width: 2 +ytick.minor.width: 2 -xtick.major.pad: 11.2 -ytick.major.pad: 11.2 +xtick.major.size: 12 +ytick.major.size: 12 +xtick.minor.size: 8 +ytick.minor.size: 8 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-talk.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-talk.mplstyle index 29a77c53c4a8..9e2fbeeb1782 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-talk.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-talk.mplstyle @@ -1,21 +1,24 @@ -# Seaborn talk context -figure.figsize: 10.4, 7.15 -axes.labelsize: 14.3 -axes.titlesize: 15.6 -xtick.labelsize: 13 -ytick.labelsize: 13 -legend.fontsize: 13 +# seaborn talk context +# see seaborn.rcmod.plotting_context() +font.size: 18 +axes.labelsize: 18 +axes.titlesize: 18 +xtick.labelsize: 16.5 +ytick.labelsize: 16.5 +legend.fontsize: 16.5 -grid.linewidth: 1.3 -lines.linewidth: 2.275 -patch.linewidth: 0.39 -lines.markersize: 9.1 -lines.markeredgewidth: 0 +axes.linewidth: 1.875 +grid.linewidth: 1.5 +lines.linewidth: 2.25 +lines.markersize: 9 +patch.linewidth: 1.5 -xtick.major.width: 1.3 -ytick.major.width: 1.3 -xtick.minor.width: 0.65 -ytick.minor.width: 0.65 +xtick.major.width: 1.875 +ytick.major.width: 1.875 +xtick.minor.width: 1.5 +ytick.minor.width: 1.5 -xtick.major.pad: 9.1 -ytick.major.pad: 9.1 +xtick.major.size: 9 +ytick.major.size: 9 +xtick.minor.size: 6 +ytick.minor.size: 6 diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-ticks.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-ticks.mplstyle index c2a1cab9a5eb..894417101110 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-ticks.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-ticks.mplstyle @@ -1,30 +1,41 @@ -# Seaborn common parameters -# .15 = dark_gray -# .8 = light_gray +# seaborn ticks style + +# common parameters (see style_dict in seaborn.rcmod.axes_style()): figure.facecolor: white -text.color: .15 axes.labelcolor: .15 -legend.frameon: False -legend.numpoints: 1 -legend.scatterpoints: 1 + xtick.direction: out ytick.direction: out xtick.color: .15 ytick.color: .15 + axes.axisbelow: True -image.cmap: Greys -font.family: sans-serif -font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif grid.linestyle: - + +text.color: .15 +font.family: sans-serif +font.sans-serif: Arial, DejaVu Sans, Liberation Sans, Bitstream Vera Sans, sans-serif + lines.solid_capstyle: round +patch.edgecolor: w +patch.force_edgecolor: True + +# seaborn image.cmap is "rocket", but we do not have that +image.cmap: Greys -# Seaborn white parameters +xtick.top: False +ytick.right: False + + +# white parameters axes.grid: False axes.facecolor: white axes.edgecolor: .15 -axes.linewidth: 1.25 grid.color: .8 -xtick.major.size: 6 -ytick.major.size: 6 -xtick.minor.size: 3 -ytick.minor.size: 3 +axes.spines.left: True +axes.spines.bottom: True +axes.spines.right: True +axes.spines.top: True + +xtick.bottom: True +ytick.left: True diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-white.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-white.mplstyle index dcbe3acf31da..405e1e7070e1 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-white.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-white.mplstyle @@ -1,30 +1,41 @@ -# Seaborn common parameters -# .15 = dark_gray -# .8 = light_gray +# seaborn white style + +# common parameters (see style_dict in seaborn.rcmod.axes_style()): figure.facecolor: white -text.color: .15 axes.labelcolor: .15 -legend.frameon: False -legend.numpoints: 1 -legend.scatterpoints: 1 + xtick.direction: out ytick.direction: out xtick.color: .15 ytick.color: .15 + axes.axisbelow: True -image.cmap: Greys -font.family: sans-serif -font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif grid.linestyle: - + +text.color: .15 +font.family: sans-serif +font.sans-serif: Arial, DejaVu Sans, Liberation Sans, Bitstream Vera Sans, sans-serif + lines.solid_capstyle: round +patch.edgecolor: w +patch.force_edgecolor: True + +# seaborn image.cmap is "rocket", but we do not have that +image.cmap: Greys -# Seaborn white parameters +xtick.top: False +ytick.right: False + + +# white parameters axes.grid: False axes.facecolor: white axes.edgecolor: .15 -axes.linewidth: 1.25 grid.color: .8 -xtick.major.size: 0 -ytick.major.size: 0 -xtick.minor.size: 0 -ytick.minor.size: 0 +axes.spines.left: True +axes.spines.bottom: True +axes.spines.right: True +axes.spines.top: True + +xtick.bottom: False +ytick.left: False diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn-whitegrid.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn-whitegrid.mplstyle index 612e21813e19..8d90e8ec54b2 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn-whitegrid.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn-whitegrid.mplstyle @@ -1,30 +1,41 @@ -# Seaborn common parameters -# .15 = dark_gray -# .8 = light_gray +# seaborn whitegrid style + +# common parameters (see style_dict in seaborn.rcmod.axes_style()): figure.facecolor: white -text.color: .15 axes.labelcolor: .15 -legend.frameon: False -legend.numpoints: 1 -legend.scatterpoints: 1 + xtick.direction: out ytick.direction: out xtick.color: .15 ytick.color: .15 + axes.axisbelow: True -image.cmap: Greys -font.family: sans-serif -font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif grid.linestyle: - + +text.color: .15 +font.family: sans-serif +font.sans-serif: Arial, DejaVu Sans, Liberation Sans, Bitstream Vera Sans, sans-serif + lines.solid_capstyle: round +patch.edgecolor: w +patch.force_edgecolor: True + +# seaborn image.cmap is "rocket", but we do not have that +image.cmap: Greys -# Seaborn whitegrid parameters +xtick.top: False +ytick.right: False + + +# whitegrid parameters axes.grid: True axes.facecolor: white axes.edgecolor: .8 -axes.linewidth: 1 grid.color: .8 -xtick.major.size: 0 -ytick.major.size: 0 -xtick.minor.size: 0 -ytick.minor.size: 0 +axes.spines.left: True +axes.spines.bottom: True +axes.spines.right: True +axes.spines.top: True + +xtick.bottom: False +ytick.left: False diff --git a/lib/matplotlib/mpl-data/stylelib/seaborn.mplstyle b/lib/matplotlib/mpl-data/stylelib/seaborn.mplstyle index 94b1bc837a47..e39cc09eeb83 100644 --- a/lib/matplotlib/mpl-data/stylelib/seaborn.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/seaborn.mplstyle @@ -1,57 +1,76 @@ -# default seaborn aesthetic -# darkgrid + deep palette + notebook context +# default seaborn aesthetic based on seaborn 0.9: +# style="darkgrid" +# context="notebook" +# palette="deep" -axes.axisbelow: True -axes.edgecolor: white -axes.facecolor: EAEAF2 -axes.grid: True -axes.labelcolor: .15 -axes.labelsize: 11 -axes.linewidth: 0 -axes.prop_cycle: cycler('color', ['4C72B0', '55A868', 'C44E52', '8172B2', 'CCB974', '64B5CD']) -axes.titlesize: 12 +# common parameters (see style_dict in seaborn.rcmod.axes_style()): figure.facecolor: white -figure.figsize: 8.0, 5.5 +axes.labelcolor: 0.15 -font.family: sans-serif -font.sans-serif: Arial, Liberation Sans, DejaVu Sans, Bitstream Vera Sans, sans-serif +xtick.direction: out +ytick.direction: out +xtick.color: .15 +ytick.color: .15 -grid.color: white +axes.axisbelow: True grid.linestyle: - -grid.linewidth: 1 +text.color: .15 +font.family: sans-serif +font.sans-serif: Arial, DejaVu Sans, Liberation Sans, Bitstream Vera Sans, sans-serif + +lines.solid_capstyle: round +patch.edgecolor: w +patch.force_edgecolor: True + +# seaborn image.cmap is "rocket", but we do not have that image.cmap: Greys -legend.fontsize: 10 -legend.frameon: False -legend.numpoints: 1 -legend.scatterpoints: 1 +xtick.top: False +ytick.right: False -lines.linewidth: 1.75 -lines.markeredgewidth: 0 -lines.markersize: 7 -lines.solid_capstyle: round -patch.facecolor: 4C72B0 -patch.linewidth: .3 +# darkgrid parameters +axes.grid: True +axes.facecolor: EAEAF2 +axes.edgecolor: white +grid.color: white +axes.spines.left: True +axes.spines.bottom: True +axes.spines.right: True +axes.spines.top: True -text.color: .15 +xtick.bottom: False +ytick.left: False -xtick.color: .15 -xtick.direction: out -xtick.labelsize: 10 -xtick.major.pad: 7 -xtick.major.size: 0 -xtick.major.width: 1 -xtick.minor.size: 0 -xtick.minor.width: .5 -ytick.color: .15 -ytick.direction: out -ytick.labelsize: 10 -ytick.major.pad: 7 -ytick.major.size: 0 -ytick.major.width: 1 -ytick.minor.size: 0 -ytick.minor.width: .5 +# plotting_context (see seaborn.rcmod.plotting_context()): +# notebook context = base context (scale=1) +font.size: 12 +axes.labelsize: 12 +axes.titlesize: 12 +xtick.labelsize: 11 +ytick.labelsize: 11 +legend.fontsize: 11 + +axes.linewidth: 1.25 +grid.linewidth: 1 +lines.linewidth: 1.5 +lines.markersize: 6 +patch.linewidth: 1 + +xtick.major.width: 1.25 +ytick.major.width: 1.25 +xtick.minor.width: 1 +ytick.minor.width: 1 + +xtick.major.size: 6 +ytick.major.size: 6 +xtick.minor.size: 4 +ytick.minor.size: 4 + + +# palette "deep" +axes.prop_cycle: cycler('color', ['4C72B0', 'DD8452', '55A868', 'C44E52', '8172B3', '937860', 'DA8BC3', '8C8C8C', 'CCB974', '64B5CD']) +patch.facecolor: 4C72B0 diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py index 04f6e7048b26..4ea0f83db79f 100644 --- a/lib/matplotlib/testing/conftest.py +++ b/lib/matplotlib/testing/conftest.py @@ -1,3 +1,5 @@ +from distutils.version import LooseVersion + import pytest import matplotlib @@ -92,3 +94,11 @@ def pd(): except ImportError: pass return pd + + +@pytest.fixture +def seaborn(): + seaborn = pytest.importorskip('seaborn') + if LooseVersion(seaborn.__version__) < LooseVersion('0.9'): + pytest.skip('seaborn style comparisons need at least seaborn 0.9') + return seaborn diff --git a/lib/matplotlib/tests/conftest.py b/lib/matplotlib/tests/conftest.py index 722a7ff91484..8358dd2d5174 100644 --- a/lib/matplotlib/tests/conftest.py +++ b/lib/matplotlib/tests/conftest.py @@ -1,4 +1,4 @@ from matplotlib.testing.conftest import (mpl_test_settings, mpl_image_comparison_parameters, pytest_configure, pytest_unconfigure, - pd) + pd, seaborn) diff --git a/lib/matplotlib/tests/test_style.py b/lib/matplotlib/tests/test_style.py index ce4a20780ed4..4398f0497b18 100644 --- a/lib/matplotlib/tests/test_style.py +++ b/lib/matplotlib/tests/test_style.py @@ -1,6 +1,8 @@ from collections import OrderedDict from contextlib import contextmanager +from distutils.version import LooseVersion import gc +import numpy as np from pathlib import Path from tempfile import TemporaryDirectory @@ -9,6 +11,7 @@ import matplotlib as mpl from matplotlib import pyplot as plt, style from matplotlib.style.core import USER_LIBRARY_PATHS, STYLE_EXTENSION +from matplotlib.testing.decorators import check_figures_equal PARAM = 'image.cmap' @@ -160,3 +163,93 @@ def test_xkcd_cm(): with plt.xkcd(): assert mpl.rcParams["path.sketch"] == (1, 100, 2) assert mpl.rcParams["path.sketch"] is None + + +@check_figures_equal(extensions=["png"]) +def test_seaborn_style(fig_test, fig_ref): + seaborn = pytest.importorskip('seaborn') + if LooseVersion(seaborn.__version__) < LooseVersion('0.9'): + pytest.skip('seaborn style comparisons need at least seaborn 0.9') + return seaborn + + def make_plot(fig): + ax1 = fig.add_subplot(121) + x = np.linspace(0, 14, 100) + for i in range(1, 7): + ax1.plot(x, np.sin(x + i * .5) * (7 - i) + 10) + heights = [1, 3, 8, 4, 2] + ax1.bar(range(5), heights) + ax1.bar(range(5, 10), heights) + ax1.bar(range(10, 15), heights) + ax1.set_title('lines and bars') + + ax2 = fig.add_subplot(122) + x = np.tile(np.linspace(0, 1, 20), 2).reshape(-1, 2) + x[:, 1] /= 2 + x[0, 1] = 0.8 + ax2.boxplot(x) + x = np.linspace(0.8, 2.2, 8) + ax2.plot(x, np.exp(-x), 'o') + ax2.set_title('markers and boxes') + + mpl.rcParams.update(mpl.rcParamsDefault) + plt.style.use('seaborn') + make_plot(fig_test) + + mpl.rcParams.update(mpl.rcParamsDefault) + seaborn.set() + make_plot(fig_ref) + + +@pytest.mark.parametrize( + 'style_name', ['dark', 'darkgrid', 'ticks', 'white', 'whitegrid']) +def test_seaborn_styles(seaborn, style_name): + """ + Test that after applying a style the style-related rcParams are identical + to the ones seaborn will define seaborn.rcmod.axes_style(). + """ + import seaborn.rcmod + style_dict = seaborn.rcmod.axes_style(style_name) + + mpl.rcParams.update(mpl.rcParamsDefault) + mpl.style.use(f'seaborn-{style_name}') + for key, val in style_dict.items(): + if key == 'image.cmap': + continue # we don't have the seaborn color maps + assert mpl.rcParams[key] == val, \ + f"Style '{style_name}' deviates in key '{key}'" + + +@pytest.mark.parametrize( + 'context_name', ['paper', 'notebook', 'talk', 'poster']) +def test_seaborn_context(seaborn, context_name): + """ + Test that after applying a style the context-related rcParams are identical + to the ones seaborn will define seaborn.rcmod.plotting_context(). + """ + import seaborn.rcmod + mpl.style.use(f'seaborn-{context_name}') + for key, val in seaborn.rcmod.plotting_context(context_name).items(): + assert mpl.rcParams[key] == pytest.approx(val), \ + f"Context '{context_name}' deviates in key '{key}'" + + +def test_seaborn_palettes(seaborn): + """ + Test that after applying a style rcParams['axes.prop_cycle'] is set to the + values defined in seaborn.palettes.SEABORN_PALETTES. + Test that rcParams['patch.facecolor'] is set to the first color in the + cycle. + """ + from seaborn.palettes import SEABORN_PALETTES + for name, colors in SEABORN_PALETTES.items(): + # seaborn-dark was already used for the dark style. + # Therefore, Matplotlib uses seaborn-dark-palette as mpl style name. + deviating_mpl_style_name = { + 'dark': 'dark-palette', + 'dark6': 'dark6-palette', + } + name = deviating_mpl_style_name.get(name, name) + mpl.style.use(f'seaborn-{name}') + assert mpl.rcParams['axes.prop_cycle'].by_key()['color'] == colors + assert mpl.rcParams['patch.facecolor'] == colors[0] diff --git a/requirements/testing/travis36.txt b/requirements/testing/travis36.txt index 0667058cd533..b8c0cbcd456f 100644 --- a/requirements/testing/travis36.txt +++ b/requirements/testing/travis36.txt @@ -4,3 +4,4 @@ ipykernel nbconvert[execute] pandas pytz +seaborn>0.9