Skip to content

Add 3 new styles with color schemes from Tableau [backport to 1.4.x] #3700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rearrange styles
Now there are 4 styles in total. Tableau 10, Tableau 20, and Tableau’s
color blind friendly all enact color style changes. The “clean” style
performs all of my custom plot formatting, as seen in the “Bachelors
degree” example.

I removed the figsize changes in my custom formatting.

Examples have also been updated in accordance with the changes.
  • Loading branch information
rhiever committed Oct 30, 2014
commit 98c1d8c3c4b32894d1db58d1cee4ccf3307dd9f0
5 changes: 3 additions & 2 deletions examples/showcase/bachelors_degrees_by_gender.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from matplotlib.mlab import csv2rec
from matplotlib.cbook import get_sample_data

# Activate the Tableau 20 styling. This call does most of the styling for you.
plt.style.use("tableau20")
# Activate the Tableau 20 and clean styling.
# This call does most of the styling for you.
plt.style.use(["clean", "tableau_20colors"])

fname = get_sample_data("percent_bachelors_degrees_women_usa.csv")
gender_degree_data = csv2rec(fname)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
This shows an example of the "tableau10" styling, which
uses Tableau's "Tableau10" color scheme.
This shows an example of the "clean" styling.
"""


Expand All @@ -9,7 +8,7 @@

x = np.linspace(0, 10)

with plt.style.context('tableau10'):
with plt.style.context('clean'):
plt.plot(x, np.sin(x) + x + np.random.randn(50))
plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50))
Expand Down
20 changes: 20 additions & 0 deletions examples/style_sheets/plot_colorblind_10colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
This shows an example of the "colorblind_10colors" styling,
which uses Tableau's "Color Blind 10" color scheme.
"""


from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(0, 10)

with plt.style.context('colorblind_10colors'):
plt.plot(x, np.sin(x) + x + np.random.randn(50))
plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 3 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 4 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 5 * x + np.random.randn(50))

plt.show()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This shows an example of the "colorblind10" styling, which
uses Tableau's "Color Blind 10" color scheme.
This shows an example of the "tableau_10colors" styling,
which uses Tableau's "Tableau 10" color scheme.
"""


Expand All @@ -9,7 +9,7 @@

x = np.linspace(0, 10)

with plt.style.context('colorblind10'):
with plt.style.context('tableau_10colors'):
plt.plot(x, np.sin(x) + x + np.random.randn(50))
plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This shows an example of the "tableau10" styling, which
uses Tableau's "Tableau20" color scheme.
This shows an example of the "tableau_20colors" styling,
which uses Tableau's "Tableau 20" color scheme.
"""


Expand All @@ -9,7 +9,7 @@

x = np.linspace(0, 10)

with plt.style.context('tableau20'):
with plt.style.context('tableau_20colors'):
plt.plot(x, np.sin(x) + x + np.random.randn(50))
plt.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50))
plt.plot(x, np.sin(x) + 2 * x + np.random.randn(50))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Author: Randal S. Olson (randalolson.com / @randal_olson)
# Uses Tableau's Tableau10 color scheme
# Produces a clean plotting template with default matplotlib colors.

figure.figsize: 12, 7
figure.edgecolor: white
figure.facecolor: white

Expand All @@ -14,7 +13,6 @@ legend.fancybox: True

font.size: 14

axes.color_cycle: 1f77b4, ff7f0e, 2ca02c, d62728, 9467bd, 8c564b, e377c2, 7f7f7f, bcbd22, 17becf
axes.linewidth: 0
axes.titlesize: 22
axes.labelsize: 16
Expand Down
37 changes: 0 additions & 37 deletions lib/matplotlib/mpl-data/stylelib/colorblind10.mplstyle

This file was deleted.

4 changes: 4 additions & 0 deletions lib/matplotlib/mpl-data/stylelib/colorblind_10colors.mplstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Author: Randal S. Olson (randalolson.com / @randal_olson)
# Uses Tableau's Color Blind 10 color scheme

axes.color_cycle: 006ba4, ff800e, ababab, 595959, 5f9ed1, c85200, 898989, a2c8ec, ffbc79, cfcfcf
38 changes: 0 additions & 38 deletions lib/matplotlib/mpl-data/stylelib/tableau20.mplstyle

This file was deleted.

4 changes: 4 additions & 0 deletions lib/matplotlib/mpl-data/stylelib/tableau_10colors.mplstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Author: Randal S. Olson (randalolson.com / @randal_olson)
# Uses Tableau's Tableau 10 color scheme

axes.color_cycle: 1f77b4, ff7f0e, 2ca02c, d62728, 9467bd, 8c564b, e377c2, 7f7f7f, bcbd22, 17becf
4 changes: 4 additions & 0 deletions lib/matplotlib/mpl-data/stylelib/tableau_20colors.mplstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Author: Randal S. Olson (randalolson.com / @randal_olson)
# Uses Tableau's Tableau 20 color scheme

axes.color_cycle: 1f77b4, aec7e8, ff7f0e, ffbb78, 2ca02c, 98df8a, d62728, ff9896, 9467bd, c5b0d5, 8c564b, c49c94, e377c2, f7b6d2, 7f7f7f, c7c7c7, bcbd22, dbdb8d, 17becf, 9edae5