-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
WIP: Use color cycle in more places #5584
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
Changes from all commits
915cef7
568042b
e2d7db3
2108b57
18f47f2
a3c338a
a869e1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from matplotlib.externals.six.moves import reduce, xrange, zip, zip_longest | ||
|
||
import math | ||
import itertools | ||
import warnings | ||
|
||
import numpy as np | ||
|
@@ -2446,7 +2447,7 @@ def pie(self, x, explode=None, labels=None, colors=None, | |
Call signature:: | ||
|
||
pie(x, explode=None, labels=None, | ||
colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'), | ||
colors=None, | ||
autopct=None, pctdistance=0.6, shadow=False, | ||
labeldistance=1.1, startangle=None, radius=None, | ||
counterclock=True, wedgeprops=None, textprops=None, | ||
|
@@ -2554,9 +2555,20 @@ def pie(self, x, explode=None, labels=None, colors=None, | |
raise ValueError("'label' must be of length 'x'") | ||
if len(x) != len(explode): | ||
raise ValueError("'explode' must be of length 'x'") | ||
if colors is None: | ||
if ((colors is None) and | ||
('color' in self._get_patches_for_fill._prop_keys)): | ||
def get_next_color(): | ||
return six.next( | ||
self._get_patches_for_fill.prop_cycler)['color'] | ||
elif colors is None: | ||
colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w') | ||
|
||
if colors is not None: | ||
color_cycler = itertools.cycle(colors) | ||
|
||
def get_next_color(): | ||
return six.next(color_cycler) | ||
|
||
if radius is None: | ||
radius = 1 | ||
|
||
|
@@ -2591,7 +2603,7 @@ def pie(self, x, explode=None, labels=None, colors=None, | |
|
||
w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2), | ||
360. * max(theta1, theta2), | ||
facecolor=colors[i % len(colors)], | ||
facecolor=get_next_color(), | ||
**wedgeprops) | ||
slices.append(w) | ||
self.add_patch(w) | ||
|
@@ -2859,6 +2871,10 @@ def xywhere(xs, ys, mask): | |
ys = [thisy for thisy, b in zip(ys, mask) if b] | ||
return xs, ys | ||
|
||
# Set an explicit color so the color cycle doesn't advance. It | ||
# will be set to the correct color where `ecolor` is handled | ||
# below. | ||
kwargs['color'] = 'k' | ||
plot_kw = {'label': '_nolegend_'} | ||
if capsize is None: | ||
capsize = rcParams["errorbar.capsize"] | ||
|
@@ -2873,7 +2889,8 @@ def xywhere(xs, ys, mask): | |
plot_kw['markeredgewidth'] = capthick | ||
# For backwards-compat, allow explicit setting of | ||
# 'mew' or 'markeredgewidth' to over-ride capthick. | ||
for key in ('markeredgewidth', 'mew', 'transform', 'alpha', 'zorder'): | ||
for key in ('markeredgewidth', 'mew', 'transform', 'alpha', 'zorder', | ||
'color'): | ||
if key in kwargs: | ||
plot_kw[key] = kwargs[key] | ||
|
||
|
@@ -3010,16 +3027,15 @@ def xywhere(xs, ys, mask): | |
if not barsabove and plot_line: | ||
l0, = self.plot(x, y, fmt, label='_nolegend_', **kwargs) | ||
|
||
if ecolor is None: | ||
if l0 is None and 'color' in self._get_lines._prop_keys: | ||
ecolor = six.next(self._get_lines.prop_cycler)['color'] | ||
else: | ||
ecolor = l0.get_color() | ||
if 'color' in self._get_lines._prop_keys: | ||
ecolor = six.next(self._get_lines.prop_cycler)['color'] | ||
|
||
for l in barcols: | ||
l.set_color(ecolor) | ||
for l in caplines: | ||
l.set_color(ecolor) | ||
if l0 is not None: | ||
l0.set_color(ecolor) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this stuff getting changed? It is already using the property cycle. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to make sure that all of the pieces of the errorbar have the same color, we have to forcibly set the colors at the end. I realised since that by not using |
||
|
||
self.autoscale_view() | ||
self._hold = holdstate | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent to not line up with codeblock