-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Refactor SurfaceLike trait #3106
Conversation
Compile Times benchmarkNote, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running: using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
|
CairoMakie adds some red tones into the surface plot for some reason: But that also happens on master and has nothing to do with this pr: @SimonDanisch @jkrumbiegel What do you think about these changes? Should we add them to the next breaking release? |
Those changes sound good to me. Can we convert ranges to intervals for |
Oh right, that was a pretty aggressive change and I didn't actually check if it was ok... The behavior for irregular xs/ys and nonlinear transform functions in image is currently:
Heatmap with My assumption was that irregular images didn't work across the board so that an interval didn't remove any functionality. Since that's not true the question is whether we want to actually support that. CairoMakie and GLMakie currently treat an image simply as a single quad/rect, which should be a good bit faster than heatmap. If we want to support irregular images we'd probably repeat most of what heatmap does. I don't really mind reverting the interval change for images, though I might rethink the naming. With vector xs and ys I would think of image as a top-right aligned cell based grid, which would fit into the GridBased branch of conversions but needs to be contrasted with heatmaps center aligned cell grids. |
Yeah I think that's actually a very good distinction between heatmap and image that we should emphasize? I'm fine with specifying the boundaries of an image quad via intervals, while it makes sense I think to specify cell centers for the heatmap because you can shift those around. Not sure what we currently do if a range passed to heatmap is n or n+1 long (compared to the number of entries in that corresponding matrix dimension). Do we shift behavior automatically or error for one? |
function adjust_axes(::CellBasedGrid, x::AbstractVector{<:Number}, y::AbstractVector{<:Number}, z::AbstractMatrix) | ||
x̂, ŷ = map((x, y), size(z)) do v, sz | ||
return length(v) == sz ? edges(v) : v | ||
end | ||
return x̂, ŷ, z | ||
end |
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.
If n values are passed they are interpreted as centers and expanded to n+1, otherwise we just keep them. CairoMakie, GLMakie and WGLMakie are all ok with getting something other than n+1 values... I guess we should add errors here.
Simon is also OK with the restrictions to I think the pr was mostly done, but we should probably emphasize the differences between heatmap and image a bit more in their docstrings. |
0bcb774
to
7148081
Compare
010b27e
to
ee4f0cd
Compare
Should we merge this into the beta branch? |
Yes, with squash merge :) |
Continues #2831 ! Still needs to check, if I rebased correctly and didn't incorrectly apply some of the changes! ## Merged PRs - #2598 - #2746 - #2346 - #2544 - #3082 - #2868 - #3062 - #3106 - #3281 - #3246 ## TODOS - [x] fix flaky test `@test GLMakie.window_size(screen.glscreen) == scaled(screen, (W, H))` - [x] Merge axis type inferences from #2220 - [x] Test on different resolution screens, IJulia, Pluto, VSCode, Windowed - [x] rebase to only have merge commits from the PRs - [x] investigate unexpected speed ups - [x] reset camera settings from tests - [ ] check doc image generation - [x] rethink default near/far in Camera3D (compatability with OIT) - [x] merge #3246 - [x] fix WGLMakie issues/tests: - [x] fix line depth issues (see tests: ~~hexbin colorrange~~ (not new), LaTeXStrings in Axis3, Axis3 axis reversal) - [x] fix lighting of surface with nan points (fixed in #3246) - ~~volume/3D contour artifacts (see 3D Contour with 2D contour slices)~~ not new - ~~artifacting in "colorscale (lines)"~~ not new - [x] GLMakie: - [x] slight outline in "scatter image markers" test - ~~clipping/z-fighting in "volume translated"~~ not new - [x] CairoMakie: - ~~Artfiacting in `colorscale (lines)"~~ not new - ~~markersize in "scatter rotations" changed?~~ not new - ~~color change in "colorscale (poly)"~~ not new - ~~transparency/render order of "OldAxis + Surface"~~ not new - ~~render order in "Merged color mesh"~~ not new - ~~render order of "Surface + wireframe + contour"~~ not new - [x] Check "SpecApi in convert_arguments" (colors swapped?) ## Fixes the following errors - fixes #2721 via #2746 - fixes #1600 via #2746 - fixes #1236 via #2746 - fixes MakieOrg/GeoMakie.jl#133 via #2598 - closes #2522 - closes #3239 via #3246 - fixes #3238 via #3246 - fixes #2985 via #3246 - fixes #3307 via #3281
Description
This pr breaks up the
SurfaceLike
trait and its childrenContinuousSurface
andDiscreteSurface
into 3 (4) new traits:GridBased
which more or less replaces SurfaceLike. The name change is meant to remove the association with Surface plots which is misleading imo.CellBasedGrid <: GridBased
which replacesDiscreteSurface
with no changesVertexBasedGrid <: GridBased
which replacesContinuousSurface
for surface, contour and contourf plots. The only change here is to default to a1:size(zs, dim)
instead of0:size(zs, dim)
. This fixes the alignment issue noted in Cannot plotcontour
s in both CairoMakie and GLMakie #3060 and a similar issue noted for surface in Fix mesh/surface with NaN points #2598.ImageLike
which replaces ContinuousSurface specifically for image plots. This no longer produces arrays in the conversion pipeline, but instead just an interval. In backends an image plot is treated as a single quad so I don't think this removes anythingIn #2598 there is a picture which shows how vertices are aligned for surface plots:
After this pr they would be aligned to integer x and y values instead, starting at (1, 1).
Example after pr: (should only change placement and scale)
With this and #3102 adding
voronoiplot
, maybe we can consider #748 done?TODO:
Type of change
Changes placements of some plots and may break some
convert_arguments
methods.Checklist