Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4f560f7

Browse files
committed
Broadcast in fill_between{,x} as well.
Also fixes a bug in fill_between with masked data. In the modified testfigures, the area in green is supposed to correspond to the part of thehatched area where the curve is below y=2. The new behavior is thecorrect one.
1 parentb4296f4 commit4f560f7

File tree

4 files changed

+94
-113
lines changed

4 files changed

+94
-113
lines changed

‎lib/matplotlib/axes/_axes.py‎

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
unicode_literals)
33

44
importsix
5-
fromsix.movesimportreduce,xrange,zip,zip_longest
5+
fromsix.movesimportxrange,zip,zip_longest
66

77
fromcollectionsimportSized
8+
importfunctools
89
importitertools
910
importmath
1011
importwarnings
@@ -4714,22 +4715,12 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
47144715
raiseValueError('Input passed into argument "%r"'%name+
47154716
'is not 1-dimensional.')
47164717

4717-
ify1.ndim==0:
4718-
y1=np.ones_like(x)*y1
4719-
ify2.ndim==0:
4720-
y2=np.ones_like(x)*y2
4721-
47224718
ifwhereisNone:
4723-
where=np.ones(len(x),np.bool)
4724-
else:
4725-
where=np.asarray(where,np.bool)
4726-
4727-
ifnot (x.shape==y1.shape==y2.shape==where.shape):
4728-
raiseValueError("Argument dimensions are incompatible")
4719+
where=True
4720+
where=where&~functools.reduce(np.logical_or,
4721+
map(np.ma.getmask, [x,y1,y2]))
47294722

4730-
mask=reduce(ma.mask_or, [ma.getmask(a)forain (x,y1,y2)])
4731-
ifmaskisnotma.nomask:
4732-
where&=~mask
4723+
x,y1,y2=np.broadcast_arrays(np.atleast_1d(x),y1,y2)
47334724

47344725
polys= []
47354726
forind0,ind1inmlab.contiguous_regions(where):
@@ -4875,22 +4866,12 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
48754866
raiseValueError('Input passed into argument "%r"'%name+
48764867
'is not 1-dimensional.')
48774868

4878-
ifx1.ndim==0:
4879-
x1=np.ones_like(y)*x1
4880-
ifx2.ndim==0:
4881-
x2=np.ones_like(y)*x2
4882-
48834869
ifwhereisNone:
4884-
where=np.ones(len(y),np.bool)
4885-
else:
4886-
where=np.asarray(where,np.bool)
4887-
4888-
ifnot (y.shape==x1.shape==x2.shape==where.shape):
4889-
raiseValueError("Argument dimensions are incompatible")
4870+
where=True
4871+
where=where&~functools.reduce(np.logical_or,
4872+
map(np.ma.getmask, [y,x1,x2]))
48904873

4891-
mask=reduce(ma.mask_or, [ma.getmask(a)forain (y,x1,x2)])
4892-
ifmaskisnotma.nomask:
4893-
where&=~mask
4874+
y,x1,x2=np.broadcast_arrays(np.atleast_1d(y),x1,x2)
48944875

48954876
polys= []
48964877
forind0,ind1inmlab.contiguous_regions(where):
Binary file not shown.
147 Bytes
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp