From c43f4fd23ae704e6ab87f5f003ba05ae7d51e39d Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 6 Feb 2017 17:45:42 -0500 Subject: [PATCH] FIX: in errorbar discard any kwargs which have None value Passing in `None` is a request from the user to 'do the default thing', but by keeping the key:value in the kwargs dict it prevents the default errorbar behavior and falls through to default Line2D behavior which is likely not what is wanted. closes #7899 --- lib/matplotlib/axes/_axes.py | 3 +++ lib/matplotlib/tests/test_axes.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index be58e8137b8d..4e7d4f18b785 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2798,6 +2798,9 @@ def errorbar(self, x, y, yerr=None, xerr=None, .. plot:: mpl_examples/statistics/errorbar_demo.py """ kwargs = cbook.normalize_kwargs(kwargs, _alias_map) + # anything that comes in as 'None', drop so the default thing + # happens down stream + kwargs = {k: v for k, v in kwargs.items() if v is not None} kwargs.setdefault('zorder', 2) if errorevery < 1: diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index bef80307b61f..4ee4e52e2846 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -2365,6 +2365,22 @@ def test_errorbar(): ax.set_title("Simplest errorbars, 0.2 in x, 0.4 in y") +@cleanup +def test_errorbar_colorcycle(): + + f, ax = plt.subplots() + x = np.arange(10) + y = 2*x + + e1, _, _ = ax.errorbar(x, y, c=None) + e2, _, _ = ax.errorbar(x, 2*y, c=None) + ln1, = ax.plot(x, 4*y) + + assert mcolors.to_rgba(e1.get_color()) == mcolors.to_rgba('C0') + assert mcolors.to_rgba(e2.get_color()) == mcolors.to_rgba('C1') + assert mcolors.to_rgba(ln1.get_color()) == mcolors.to_rgba('C2') + + @cleanup def test_errorbar_shape(): fig = plt.figure() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy