Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first cut at an alternate take to zooming, focusing on the programmatic API first rather than the interaction. This exposes a plot.rescale method that takes scale definitions, allowing scales to be modified after a plot is rendered; the plot is re-rendered in place with the new scale definitions.
For zooming, we would use plot.rescale to redefine the x and y domains (or, in the case of an ordinal position scale, we might redefine the range instead). But the plot.rescale method could have other uses as well, such as adjusting the r scale as you zoom in or out, switching from a linear to a log scale, redefining the color scale to highlight certain elements, and so on.
Additionally, it should be simpler to sketch this if we focus on the programmatic API first. We should be able to easily implement interactive zooming and zoom transitions on top of this API. Here is a little demo of a panning animation:
Screen.Recording.2024-11-23.at.7.21.07.PM.mov
The implementation so far is as minimal as I could make it. A new plot is rendered with the new options, and then the contents of the old plot are replaced with the contents of the new plot. I don’t think this approach will work as-is (for example, I think it breaks the tip mark); but I think we can make a smarter, faster implementation that has the same API.
We also need to figure out what scale options are valid to pass to plot.rescale. Since these options are merged not with the original options, but with the materialized scales, the results may not be what you expect; for example, passing the scheme option for a color scale typically has no effect because it is lower priority than the materialized range or interpolate option.
Fixes #1590.
Previously #2083 #1964 #1738.