New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interpolate_curve operation and Curve interpolation plot option #1097

Merged
merged 1 commit into from Feb 13, 2017

Conversation

Projects
None yet
2 participants
@philippjfr
Member

philippjfr commented Feb 1, 2017

Recently I prototyped a Steps Element which would plot changes in the y-values of a Curve as discrete steps. It was pointed out this really just represents different interpolation behavior for Curve plots. I think this is a good suggestion, and I'd like to start using it for a project I'm working on. I've added step_curve as a separate operation so you can also plot steps when datashading simply by applying it to the Curve before datashading is applied. Here's what it looks like:

%%opts Overlay [legend_position='right' width=600 toolbar='above']
arr = np.random.rand(10)
hv.Overlay([hv.Curve(arr, label=intp)(plot=dict(interpolation=intp))
            for intp in ['linear', 'steps-pre', 'steps-mid', 'steps-post']])

screen shot 2017-02-01 at 9 11 19 pm

@philippjfr

This comment has been minimized.

Member

philippjfr commented Feb 1, 2017

@jordansamuels I've now implemented support for stepping on Curves.

@philippjfr

This comment has been minimized.

Member

philippjfr commented Feb 1, 2017

Bit perplexed by the persistent python2 test failure. Importing from import hv.operation in plotting somehow changed some axis ranges in two bokeh chart plots (Bars and BoxWhisker)?

@jlstevens

This comment has been minimized.

Member

jlstevens commented Feb 2, 2017

I think an interpolation plot option would be very reasonable but I think the implementation should be generalized further.

I would like to see CurvePlot pass the interpolation parameter to a general interpolate_curve function (or similar) that happens to support the various step options. Right now this operation would support 'linear', 'steps-mid', 'steps-pre' and 'steps-post' but you could imagine it being extended to support additional types of interpolation in future.

return steps
class step_curve(ElementOperation):

This comment has been minimized.

@jlstevens

jlstevens Feb 2, 2017

Member

I would consider generalizing this to an interpolate_curve that supports the same interpolation options as CurvePlot - currently this would just mean adding a 'linear' option that does nothing. I would also consider making the functions above into classmethods.

@philippjfr philippjfr changed the title from Add step_curve operation and Curve interpolation plot option to Add interpolate_curve operation and Curve interpolation plot option Feb 6, 2017

@philippjfr

This comment has been minimized.

Member

philippjfr commented Feb 6, 2017

Updated, ready to merge when tests pass.

@philippjfr philippjfr added this to the v1.7.0 milestone Feb 6, 2017

@philippjfr

This comment has been minimized.

Member

philippjfr commented Feb 13, 2017

After rebasing with master this now seems to work okay, ready to merge.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Feb 13, 2017

I guess we could have bezier/splice interpolation in future by sampling a spline into a Curve - although this would make the sampling rate into a free parameter (though I suspect plotting libraries often do this behind the scenes). I wonder if we could have a Spline element as a subclass of Curve but I would need to think about it more...

Merging.

@jlstevens jlstevens merged commit 698d015 into master Feb 13, 2017

4 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+1.04%) to 78.215%
Details
s3-reference-data-cache Tests passing no test data changes required.
Details

@philippjfr philippjfr deleted the step_operation branch Feb 23, 2017

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