Fix containment and subslice optim. for steps. #6645

Merged
merged 2 commits into from Jul 12, 2016

Conversation

Projects
None yet
3 participants
Contributor

anntzer commented Jun 26, 2016

#6497 set the _path attribute of Line2D to the actually drawn path
even if the drawstyle is steps-*; however containment tests and the
subslice optimization for very long paths were not updated accordingly
(see #6615). This patch fixes the issues.

Note that contains returns, for events in a horizontal segment of a
"steps-mid" drawstyle plot, the index of the point in the segment,
regardless of whether the event occured to the left or the right of
that point.

@anntzer anntzer Fix containment and subslice optim. for steps.
 #6497 set the `_path` attribute of Line2D to the actually drawn path
even if the drawstyle is `steps-*`; however containment tests and the
subslice optimization for very long paths were not updated accordingly
(see #6615).  This patch fixes the issues.

Note that `contains` returns, for events in a horizontal segment of a
"steps-mid" drawstyle plot, the index of the point in the segment,
regardless of whether the event occured to the left or the right of
that point.
13b4555

mdboom added the needs_review label Jun 26, 2016

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

@tacaswell tacaswell commented on the diff Jun 29, 2016

lib/matplotlib/lines.py
@@ -693,8 +696,9 @@ def _transform_path(self, subslice=None):
"""
# Masked arrays are now handled by the Path class itself
if subslice is not None:
- _steps = self._path._interpolation_steps
- _path = Path(self._xy[subslice, :], _interpolation_steps=_steps)
+ xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy[subslice, :].T)
+ _path = Path(np.asarray(xy).T,
@tacaswell

tacaswell Jun 29, 2016

Owner

Can you add a test image for this?

@anntzer

anntzer Jun 29, 2016

Contributor

done

@anntzer anntzer Adapt drawstyles test.
Remove duplicated test as well.
e7dd0e3

tacaswell closed this Jul 12, 2016

tacaswell reopened this Jul 12, 2016

@tacaswell tacaswell added needs_review and removed needs_review labels Jul 12, 2016

@tacaswell tacaswell commented on the diff Jul 12, 2016

lib/matplotlib/tests/test_axes.py
@@ -4460,12 +4460,6 @@ def test_ls_ds_conflict():
linestyle='steps-pre:', drawstyle='steps-post')
-@cleanup
-def test_ls_ds_conflict():
@tacaswell

tacaswell Jul 12, 2016

Owner

why remove this?

@anntzer

anntzer Jul 12, 2016

Contributor

It is duplicated (see the lines just above).

@tacaswell

tacaswell Jul 12, 2016

Owner

Ah, that is a good reason to remove it.

@tacaswell tacaswell merged commit 239e5f0 into matplotlib:master Jul 12, 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 increased (+0.04%) to 70.327%
Details

tacaswell removed the needs_review label Jul 12, 2016

anntzer deleted the anntzer:drawstyle-index-and-subslice branch Jul 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment