From 9ecfd0914d9bb1880cc04a127063308d13e66838 Mon Sep 17 00:00:00 2001 From: Bhanu Teja Kasani <40614174+kasanitej@users.noreply.github.com> Date: Sun, 31 Mar 2019 19:28:48 -0400 Subject: [PATCH 1/3] incorrect error bar colors when NaN values are present BUG:13799 --- lib/matplotlib/axes/_axes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 4630a7568818..4e254649a264 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3211,6 +3211,19 @@ def errorbar(self, x, y, yerr=None, xerr=None, if not np.iterable(y): y = [y] + # The actual errorbar function works even if lengths of x and y + # dont matches with "ecolor" inorder to retain the same behavior + # the new change will only effect if lengths matches + if iterable(ecolor) and len(ecolor) == len(x) and len(ecolor) == len(y): + # To get np.nan indices in both x and y lists + nan_indices = list(np.where(np.isnan(x))[ + 0]) + list(np.where(np.isnan(y))[0]) + # To remove duplicates + nan_indices = list(set(nan_indices)) + ecolor = np.array(ecolor) + # To delete colors corrresonding to np.nan in x and y + ecolor = np.delete(ecolor, nan_indices) + ecolor = list(ecolor) if xerr is not None: if not np.iterable(xerr): From 397fb95b4c795fec41012316d294dfaf4a2d0249 Mon Sep 17 00:00:00 2001 From: Bhanu Teja Kasani <40614174+kasanitej@users.noreply.github.com> Date: Sun, 31 Mar 2019 20:52:16 -0400 Subject: [PATCH 2/3] incorrect error bar colors when NaN values are present BUG:13799 --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 4e254649a264..6a670b6d7c93 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3214,7 +3214,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, # The actual errorbar function works even if lengths of x and y # dont matches with "ecolor" inorder to retain the same behavior # the new change will only effect if lengths matches - if iterable(ecolor) and len(ecolor) == len(x) and len(ecolor) == len(y): + if np.iterable(ecolor) and len(ecolor) == len(x) and len(ecolor) == len(y): # To get np.nan indices in both x and y lists nan_indices = list(np.where(np.isnan(x))[ 0]) + list(np.where(np.isnan(y))[0]) From efc418dff8d1f0eb5dc7f4abc4f7dabee1434774 Mon Sep 17 00:00:00 2001 From: Bhanu Teja Kasani <40614174+kasanitej@users.noreply.github.com> Date: Sun, 31 Mar 2019 22:14:53 -0400 Subject: [PATCH 3/3] flake 8 changes --- lib/matplotlib/axes/_axes.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 6a670b6d7c93..0462132e0141 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3214,16 +3214,17 @@ def errorbar(self, x, y, yerr=None, xerr=None, # The actual errorbar function works even if lengths of x and y # dont matches with "ecolor" inorder to retain the same behavior # the new change will only effect if lengths matches - if np.iterable(ecolor) and len(ecolor) == len(x) and len(ecolor) == len(y): - # To get np.nan indices in both x and y lists - nan_indices = list(np.where(np.isnan(x))[ - 0]) + list(np.where(np.isnan(y))[0]) - # To remove duplicates - nan_indices = list(set(nan_indices)) - ecolor = np.array(ecolor) - # To delete colors corrresonding to np.nan in x and y - ecolor = np.delete(ecolor, nan_indices) - ecolor = list(ecolor) + if np.iterable(ecolor): + if len(ecolor) == len(x) and len(ecolor) == len(y): + # To get np.nan indices in both x and y lists + nan_indices = list(np.where(np.isnan(x))[ + 0]) + list(np.where(np.isnan(y))[0]) + # To remove duplicates + nan_indices = list(set(nan_indices)) + ecolor = np.array(ecolor) + # To delete colors corrresonding to np.nan in x and y + ecolor = np.delete(ecolor, nan_indices) + ecolor = list(ecolor) if xerr is not None: if not np.iterable(xerr):