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

Skip to content

Commit 71dc0e6

Browse files
committed
add masked array support to fill_between
svn path=/trunk/matplotlib/; revision=7070
1 parent c8437cb commit 71dc0e6

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

examples/user_interfaces/embedding_in_gtk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from numpy import arange, sin, pi
1111

1212
# uncomment to select /GTK/GTKAgg/GTKCairo
13-
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
14-
#from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
13+
#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
14+
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
1515
#from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas
1616

1717

examples/user_interfaces/embedding_in_gtk2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from numpy import arange, sin, pi
1010

1111
# uncomment to select /GTK/GTKAgg/GTKCairo
12-
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
13-
#from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
12+
#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
13+
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
1414
#from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas
1515

1616
# or NavigationToolbar for classic

lib/matplotlib/axes.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5832,6 +5832,26 @@ def fill_between(self, x, y1, y2=0, where=None, **kwargs):
58325832
self._process_unit_info(xdata=x, ydata=y1, kwargs=kwargs)
58335833
self._process_unit_info(ydata=y2)
58345834

5835+
if where is None:
5836+
where = np.ones(len(x), np.bool)
5837+
else:
5838+
where = np.asarray(where)
5839+
5840+
maskedx = isinstance(x, np.ma.MaskedArray)
5841+
maskedy1 = isinstance(y1, np.ma.MaskedArray)
5842+
maskedy2 = isinstance(y2, np.ma.MaskedArray)
5843+
5844+
if (maskedx or maskedy1 or maskedy2):
5845+
if maskedx:
5846+
where = where & (~x.mask)
5847+
5848+
if maskedy1:
5849+
where = where & (~y1.mask)
5850+
5851+
if maskedy2:
5852+
where = where & (~y2.mask)
5853+
5854+
58355855
# Convert the arrays so we can work with them
58365856
x = np.asarray(self.convert_xunits(x))
58375857
y1 = np.asarray(self.convert_yunits(y1))
@@ -5843,10 +5863,7 @@ def fill_between(self, x, y1, y2=0, where=None, **kwargs):
58435863
if not cbook.iterable(y2):
58445864
y2 = np.ones_like(x)*y2
58455865

5846-
if where is None:
5847-
where = np.ones(len(x), np.bool)
58485866

5849-
where = np.asarray(where)
58505867
assert( (len(x)==len(y1)) and (len(x)==len(y2)) and len(x)==len(where))
58515868

58525869
polys = []

0 commit comments

Comments
 (0)