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

Skip to content
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
Next Next commit
Fix color cycle usage in errorbar
  • Loading branch information
mdboom committed Nov 30, 2015
commit e2d7db38943e900e807bdb89e49cc8fe93d82142
16 changes: 10 additions & 6 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2868,6 +2868,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"]
Expand All @@ -2882,7 +2886,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]

Expand Down Expand Up @@ -3019,16 +3024,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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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 plt.plot internally but by using Axes.line2d directly we can probably avoid all this nonsense.


self.autoscale_view()
self._hold = holdstate
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading