-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Interpolate contours in linear space, not data space #5985
Conversation
Thanks very much for the PR. |
@alexcjohnson I think the way contours are working on master is actually correct. |
"correct" is a bit open to interpretation when it comes to interpolation, but I think what @andrew-matteson has implemented here is more useful. If you've displayed your data on a log axis, the implication is that variations tend to be smoother on a log scale, hence that's the space in which it makes sense to interpolate it. For reference here's what the new mock would look like with the existing interpolation: Pretty obviously worse than the version added in this PR, I'd say. @archmoj do you have a case in mind where the existing interpolation is preferable? |
You could ask the same question about lines connecting points on a scatter plot - we should connect them with a straight line in data space, then transform that line to log axes where it would be a curve. But that's not what we do: even with log axes we connect with a straight line in pixel space (or, if you've selected spline shape, with a bezier curve calculated in pixel space) and I think displaying the data on log axes is a way of saying that, in general, that's also the space you should be interpolating in. This PR is the equivalent for contours. Perhaps at some point the current behavior could be provided as an option, but to me this PR seems a much better default behavior. |
4 contour plots of a sparsely sampled cone with x/y chosen so the plot contours appear the same.
revert short circuit of `ya.c2p(ya.l2c(...))` as `ya.l2p(...)` because it breaks carpet contours
3d6152f
to
9b87939
Compare
I sort of agree with this part |
draftlogs/5985_fix.md
Outdated
@@ -0,0 +1 @@ | |||
- Improve drawing the contour lines in non-linear space e.g. on log axes [[#5985](https://github.com/plotly/plotly.js/pull/5985)], with thanks to @andrew-matteson for the contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we rename this file to 5985_change.md
so that it clearly show up in the Changed
section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense to me - this PR is somewhere between a fix and a change, so let's put it in the somewhat more prominent place (and release it in a minor rather than a patch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 I'd say this is ready once the changelog entry is moved to change
- thanks @andrew-matteson!
FYI I created #5991 to track the heatmap brick edge issue I noted in my earlier comment.
284ea38
to
1dea4a7
Compare
Fixes #5899
Contours are determined by interpolation. When the x or y axis is non-linear, the interpolation should be non-linear.
This PR changes calculates a linearized
dx
anddy
, then uses then converts back into pixel space. I've added a test to the dashboard of contour plots of 4 sparsely sampled "cones" that should all have the same fill colors/shapes if interpolation is handled correctly.