From 7e8602fbedeb23083422f9545fcd8038231a4b6a Mon Sep 17 00:00:00 2001 From: Genki Takahashi Date: Fri, 1 Feb 2019 01:18:13 +0900 Subject: [PATCH] change color_cycle into prop_cycle to and use cycler to feed to matplotlib.rcParams. This change fix KeyError in the issue#100. --- prettyplotlib/colors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prettyplotlib/colors.py b/prettyplotlib/colors.py index e5a5232..13bb735 100644 --- a/prettyplotlib/colors.py +++ b/prettyplotlib/colors.py @@ -4,7 +4,7 @@ import numpy as np import matplotlib as mpl from matplotlib import cm - +from cycler import cycler # Get Set2 from ColorBrewer, a set of colors deemed colorblind-safe and @@ -18,11 +18,11 @@ #class Common(object): # def __init__(self): -set2 = brewer2mpl.get_map('Set2', 'qualitative', 8).mpl_colors +set2 = brewer2mpl.get_map('Set2', 'qualitative', 8).hex_colors # Another ColorBrewer scale. This one has nice "traditional" colors like # reds and blues -set1 = brewer2mpl.get_map('Set1', 'qualitative', 9).mpl_colors +set1 = brewer2mpl.get_map('Set1', 'qualitative', 9).hex_colors # A colormapcycle for stacked barplots stackmaps = [brewer2mpl.get_map('YlGn', 'sequential', 8).mpl_colormap, @@ -31,7 +31,7 @@ # This context-decorator makes it possible to change the color cycle inside # prettyplotlib without affecting pyplot class _pretty: - rcParams = {'axes.color_cycle': set2, 'lines.linewidth': .75} + rcParams = {'axes.prop_cycle': cycler(color=set2), 'lines.linewidth': .75} mpl_contexts = [] def __call__(self, func):