Skip to content
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

philippjfr
Copy link
Member

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
Copy link
Member Author

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

@philippjfr
Copy link
Member Author

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
Copy link
Contributor

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Add step_curve operation and Curve interpolation plot option Add interpolate_curve operation and Curve interpolation plot option Feb 6, 2017
@philippjfr
Copy link
Member Author

Updated, ready to merge when tests pass.

@philippjfr
Copy link
Member Author

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

@jlstevens
Copy link
Contributor

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
@philippjfr philippjfr deleted the step_operation branch February 23, 2017 18:43
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants