-
Notifications
You must be signed in to change notification settings - Fork 63
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
Don’t round the corners #72
Comments
Some progress in https://observablehq.com/@d3/contours-fix-edges-72, but there are still a few unpleasant bumps as in the top-left and bottom-right of the grid0 model. |
Some update on this topic? |
I've revised the notebook above, by fixing only the corners (and not the edges anymore) I think it's much better? |
please share some data underlying the screenshots, otherwise I don't know what I'm seeing |
z is flatmapped (like data.z.reverse()).flatMap((a) => a.flatMap((b) => b)) and passed to d3.contours func created as : But the result is the same as what can been seen in your notebook by changing t : |
Thanks; added your data in the notebook as "grid2", multiply it by 5 to make it more similar to the others. I don't know exactly what plotly does, but it seems to me, looking at this basic example, that their contours are clipped at the location of the data points (whereas the d3 contours expand outward by 0.5 pixel). If you clip d3’s contours at the data points, the edge artifacts are in effect hidden and (I think) this would result in the same image. If the green lines are an indication of what you'd want the system to do, I agree that it is what looks best. I'm still not there, but I'm pretty sure there is a solution to be found. |
Ill look into clipping then. Might be better than zoom :) *) Update, inset(3%) clipping path around the polygon renderer seems to remove the artifacts in most of our cases with dataset size 16x16 (0.5 / 16 = 3%) |
Is there any update on this? I'm seeing the same issue as well. |
I've made some progress but haven't nailed it yet, sorry. |
That's cool, thanks for the update! Can you think of anything I can do to "resolve" this semi-automatically? I'm creating a wrapper around the d3 contour for internal use so I can add some "magical" code so it just "works". Currently am masking the edges but it's a bit ugly. |
Sure, see the referenced notebook. |
Ah my bad, thanks! |
Fyi, our stakeholders did not like the workaround by clipping the distorted edges. As a result we had to swap lib to https://github.com/RaumZeit/MarchingSquares.js as a temporary solution, until issue is fixed in d3-contours. Our solution now calculate isoBands using MarchingSquares.js and wraps them in the same MultiPolygon-object as produced by d3-contours so it will be easy to change lib later. |
@MattiasJa thanks for the reference; just like Plotly, RaumZeit/MarchingSquares.js clips the contours at the location of the data points. |
There are some rounded corner artifacts on the edge of the grid:
It’s much more visible with a coarser grid:
I think it’s because we assume that outside the grid, the value is effectively -Infinity (or NaN). It would be nicer if we simply repeated the edge value infinitely (like WebGL CLAMP_TO_EDGE) so that we got square corners.
/cc @Fil
The text was updated successfully, but these errors were encountered: