Fillbetween #6560

Merged
merged 1 commit into from Nov 5, 2016

Conversation

Projects
None yet
6 participants
Contributor

rmlopes commented Jun 8, 2016 edited

As discussed in issue #6543. Added the interpolate argument just before the **kwargs.

I think I made a mistake, I wanted to target the 1.5.x. I'll be waiting for some input. :)

Should I edit the changelog as well?

mdboom added the needs_review label Jun 8, 2016

Owner

tacaswell commented Jun 8, 2016

You targeted the right branch. If merged, this will ship with 2.1 at the earliest.

@tacaswell tacaswell commented on an outdated diff Jun 8, 2016

lib/matplotlib/axes/_axes.py
"""
Make filled polygons between two horizontal curves.
Call signature::
- fill_betweenx(y, x1, x2=0, where=None, **kwargs)
+ fill_betweenx(y, x1, x2=0, where=None, step=None, **kwargs)
@tacaswell

tacaswell Jun 8, 2016

Owner

can you also add interpolate here?

Owner

tacaswell commented Jun 8, 2016

Can you add an entry in docs/user/whats_new (the README in that folder has instructions).

tacaswell added this to the 2.1 (next point release) milestone Jun 8, 2016

Contributor

rmlopes commented Jun 8, 2016

What is the problem here? I can't see the indicated errors.

AssertionError: 2 != 0 : Found code syntax errors (and warnings):
/home/travis/build/matplotlib/matplotlib/lib/matplotlib/axes/_axes.py:4806:80: E501 line too long (88 > 79 characters)
/home/travis/build/matplotlib/matplotlib/lib/matplotlib/axes/_axes.py:4907:60: W291 trailing whitespace

Owner

tacaswell commented Jun 8, 2016

That is odd that it is reporting lines outside of where you touched. This may be due to a bad merge somewhere else?

Member

QuLogic commented Jun 8, 2016

master probably has some deleted lines so the merge commit that's being tested has different line numbers. However, it's pretty obvious that line 4856 is too long. As for the trailing whitespace, it will be easier if you configure your editor to strip them on save.

Contributor

rmlopes commented Jun 9, 2016 edited

There is once again a flake failure, in a line that is not part of the diff - 4908 (and I have already configured the editor to remove trailing spaces on write).

There is an unrelated test failing as well at the image comparison:
FAIL: matplotlib.tests.test_mathtext.test_mathfont_dejavusans_03.test

What should I do?

@QuLogic QuLogic commented on an outdated diff Jun 9, 2016

doc/users/whats_new/updated_fill_betweenx.rst
@@ -0,0 +1,7 @@
+Interpolation in fill_betweenx
+------------------------------
+
+The ``interpolate`` parameter now exists for the method :func:`fill_betweenx`. This allows
+a user to interpolate the data and fill the areas in the crossover points, similarly to :func:`fill_between`.
+::
@QuLogic

QuLogic Jun 9, 2016

Member

The :: indicates there will be a code block following; it should be removed (or an example added.)

@QuLogic QuLogic commented on an outdated diff Jun 9, 2016

lib/matplotlib/axes/_axes.py
@@ -4940,12 +4947,36 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
N = len(yslice)
Y = np.zeros((2 * N + 2, 2), np.float)
+ if interpolate:
+ def get_interp_point(ind):
+ im1 = max(ind - 1, 0)
+ y_values = y[im1:ind + 1]
+ diff_values = x1[im1:ind + 1] - x2[im1:ind + 1]
+ x1_values = x1[im1:ind + 1]
+
+ if len(diff_values) == 2:
+ if np.ma.is_masked(diff_values[1]):
@QuLogic

QuLogic Jun 9, 2016

Member

The trailing space is here.

Member

QuLogic commented Jun 9, 2016

There is an unrelated test failing as well at the image comparison:
FAIL: matplotlib.tests.test_mathtext.test_mathfont_dejavusans_03.test

That comes and goes; you can ignore it.

Contributor

rmlopes commented Jun 13, 2016 edited

I will implement the tests for fill_betweenx with and without interpolate because it is missing. I have had some issues with the figures in other libraries (small differences in the fonts to the generated by travis). Is there some kind of procedure (like run the test in travis first, then go to the error message to pick the expected image) in place?

Contributor

rmlopes commented Jun 23, 2016

@tacaswell I was just wondering, since this is such a trivial change, why not merge this before 2.1? Would it make a difference if the test coverage increased?

Owner

tacaswell commented Jun 23, 2016

This is a new feature and 2.1 is the next release with planned new features. The 1.5.x series is only getting critical (as in fixing regressions / does not compile / show stopper) bug fixes, and the 2.x series is only getting changes needed to get the style updates out the door.

This seems to need a rebase.

Owner

tacaswell commented Jul 12, 2016

ping @rmlopes can you rebase this?

Contributor

rmlopes commented Jul 13, 2016

@tacaswell I rebased by squashing every commit into the first, then forced the push as the history is incompatible. Looks like this may not have been the correct approach though.

Owner

tacaswell commented Jul 13, 2016

You now need to rebase that single commit onto current master and force-push again.

Contributor

rmlopes commented Jul 13, 2016

Should be ok now.

@NelleV

Overall, this looks good.
I've added a comment, but I think this PR has been going on for so long that we should merge it and do the maintenance in another PR.

- Y = np.zeros((2 * N + 2, 2), float)
+ Y = np.zeros((2 * N + 2, 2), np.float)
+ if interpolate:
+ def get_interp_point(ind):
@NelleV

NelleV Oct 29, 2016

Contributor

Is this the exact same function as in fill_between?
If so, I think it should be factored out and moved to the cbook module as a private function.

@rmlopes

rmlopes Nov 1, 2016 edited

Contributor

I think so. I thought about that but also about using some interpolation function maintained and alerady available in scipy (would this be a bad idea perhaps?). I'll have a look at it as soon as I can.

@NelleV

NelleV Nov 1, 2016

Contributor

scipy isn't a dependency, so using their functions isn't an option unless you copy paste them in a module of ours.

@rmlopes

rmlopes Nov 1, 2016

Contributor

The two methods differ on the axes of interpolation only. Could be a single function indeed. I can make this in a new branch but I need to know where to add the interpolate function.
This solution is actually very slow for my use case since I am displaying a few thousand seismic traces, so I would like to keep working on this.

Member

QuLogic commented Oct 29, 2016

Can you amend the commit and edit the commit message to remove the duplicate information and the comments from git?

NelleV changed the title from Fillbetween to [MRG+1] Fillbetween Oct 29, 2016

Contributor

rmlopes commented Nov 1, 2016

I did a rebase squashing 2 commits but somehow ended up with three commits.

Contributor

NelleV commented Nov 1, 2016

Thanks @rmlopes ! I'll merge this as soon as the tests have passed.

+Interpolation in fill_betweenx
+------------------------------
+
+The ``interpolate`` parameter now exists for the method :func:`fill_betweenx`.
@QuLogic

QuLogic Nov 1, 2016

Member

It's a method on a class, not a function, so will this cross-reference work?

lib/matplotlib/axes/_axes.py
"""
Make filled polygons between two horizontal curves.
+ Call signature::
@QuLogic

QuLogic Nov 1, 2016

Member

Please don't add the call signature back; it is redundant.

@rmlopes @rmlopes rmlopes added interpolate functionaly to fill_betweenx, as in fill_between, e…
…nabled through keyword argument interpolate.
4e9c7e7
Owner

efiring commented Nov 1, 2016

On 2016/11/01 10:10 AM, Rui Lopes wrote:

This solution is actually very slow for my use case since I am
displaying a few thousand seismic traces, so I would like to keep
working on this.

Yes, there should be some scope for vectorization here. At the very
least, all necessary interpolation can be done in a single call to
interp for the whole array. I suspect the entire operation can be
vectorized; I don't see any inherent need for loops.

Contributor

NelleV commented Nov 5, 2016

I'll merge this, but @rmlopes feel free to continue working on this and open a new PR!

@NelleV NelleV merged commit 3ff9fa8 into matplotlib:master Nov 5, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.01%) to 61.826%
Details

QuLogic changed the title from [MRG+1] Fillbetween to Fillbetween Nov 5, 2016

QuLogic removed the needs_review label Nov 24, 2016

@dopplershift dopplershift added a commit to dopplershift/MetPy that referenced this pull request Apr 17, 2017

@dopplershift dopplershift ENH: Backport fill_betweenx interpolation support (Fixes #69)
This backports matplotlib/matplotlib#6560 so that shading things like
CAPE/CIN now properly fill up to the cross-over point.
e9a78af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment