-
-
Notifications
You must be signed in to change notification settings - Fork 314
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 space=:transformed
#2766
base: master
Are you sure you want to change the base?
Add space=:transformed
#2766
Conversation
Basically data space, without applying `apply_transform`. Works pretty well. MWE: ```julia fig, ax, plt = lines(1:10, 1:10; axis = (; xscale = log10)) lines!(ax, LinRange(0, 10, 10), 1:10; space = :transformed) ``` This is useful if you want to control when the plot's transform_func is applied, especially in a recipe!
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))
|
I got a bit confused that this doesn't touch the transformation code, but there we are already only allowing Makie.jl/src/layouting/transformation.jl Line 203 in 7ff2df7
I don't like the name that much but I can see the point of this. Mixing in the opengl terminology from leanropengl we'd have
where |
Hmm, I see what you're saying but I'm not sure Another possible name might be |
Maybe it's better to leave it as is now and adjust things later if we find a better name. This stuff may need some adjustments as well: Makie.jl/src/camera/projection_math.jl Lines 317 to 345 in 2116627
It's used for scatter and text. I think it applies after transformations, so it's probably fine to consider |
already done :) yep, the idea was that it's the same projection matrix as |
Oh yea. Another question is whether this should affect limits. Since it applies before "world" space I'd say it probably should? |
What would happen if the transformation doesn't have an inverse defined? We have a nice method to deal with bounding box transformations for those transformations which are not linearly separable, but have an inverse defined. So that's there, at least. I guess we could check |
Is that not a mandatory part of the interface? If not then we have to check like this and potentially ignore. |
Unfortunately, it's not :( - at least, not when a plot is nested within a recipe. If you try putting a |
We should really overhaul this entire pipeline.
I tried to patch @recipe(Test1) do scene
Attributes()
end
# brackets were having bbox issues in recipes earlier, this should ideally look like the docs example
function Makie.plot!(p::Test1)
bracket!(p, pi/2, 1, 5pi/2, 1, offset = 5, text = "Period length", style = :square)
bracket!(p, pi/2, 1, pi/2, -1, text = "Amplitude", orientation = :down,
linestyle = :dash, rotation = 0, align = (:right, :center), textoffset = 4, linewidth = 2, color = :red, textcolor = :red)
bracket!(p, 2.3, sin(2.3), 4.0, sin(4.0),
text = "Falling", offset = 10, orientation = :up, color = :purple, textcolor = :purple)
bracket!(p, Point(5.5, sin(5.5)), Point(7.0, sin(7.0)),
text = "Rising", offset = 10, orientation = :down, color = :orange, textcolor = :orange,
fontsize = 30, textoffset = 30, width = 50)
end
fig = Figure()
test1(fig[1. 1])
fig |
src/layouting/data_limits.jl
Outdated
if space != :data | ||
tuple() | ||
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.
This should apply from the outside via exclude
Makie.jl/src/layouting/data_limits.jl
Lines 194 to 202 in ffc31a0
function data_limits(scenelike, exclude=(p)-> false) | |
bb_ref = Base.RefValue(Rect3f()) | |
foreach_plot(scenelike) do plot | |
if !exclude(plot) | |
update_boundingbox!(bb_ref, data_limits(plot)) | |
end | |
end | |
return bb_ref[] | |
end |
starting from
Makie.jl/src/makielayout/blocks/axis.jl
Lines 859 to 882 in ffc31a0
function getlimits(la::Axis, dim) | |
# find all plots that don't have exclusion attributes set | |
# for this dimension | |
if !(dim in (1, 2)) | |
error("Dimension $dim not allowed. Only 1 or 2.") | |
end | |
function exclude(plot) | |
# only use plots with autolimits = true | |
to_value(get(plot, dim == 1 ? :xautolimits : :yautolimits, true)) || return true | |
# only if they use data coordinates | |
is_data_space(to_value(get(plot, :space, :data))) || return true | |
# only use visible plots for limits | |
return !to_value(get(plot, :visible, true)) | |
end | |
# get all data limits, minus the excluded plots | |
boundingbox = Makie.data_limits(la.scene, exclude) | |
# if there are no bboxes remaining, `nothing` signals that no limits could be determined | |
Makie.isfinite_rect(boundingbox) || return nothing | |
# otherwise start with the first box | |
mini, maxi = minimum(boundingbox), maximum(boundingbox) | |
return (mini[dim], maxi[dim]) | |
end |
Scene should already be fine
Lines 571 to 583 in ffc31a0
function not_in_data_space(p) | |
!is_data_space(to_value(get(p, :space, :data))) | |
end | |
function center!(scene::Scene, padding=0.01, exclude = not_in_data_space) | |
bb = boundingbox(scene, exclude) | |
bb = transformationmatrix(scene)[] * bb | |
w = widths(bb) | |
padd = w .* padding | |
bb = Rect3f(minimum(bb) .- padd, w .+ 2padd) | |
update_cam!(scene, bb) | |
scene | |
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.
Oh actually axis should be fine as is too, since it has is_data_space(to_value(get(plot, :space, :data))) || return true
.
I would consider this a bounding box/limits problem. |
Hey @SimonDanisch, could we add this to v0.21 as well potentially? |
This PR should still work if merged, it's pretty light on changes :D. Could we get this in soon? |
Are Axis limits and Float64 conversion working fine with this after 0.21? |
Will have to check that - might just open a new PR then! |
Description
Basically data space, without applying
apply_transform
. Works pretty well.MWE:
This is useful if you want to control when the plot's transform_func is applied, especially in a recipe!
I'm working on a potential solution to plot Tyler tiles in geographic projections by plotting a pre-transformed mesh, and texturing it by the image. The WIP code is in this gist, and the relevant issue is MakieOrg/Tyler.jl#25.
More generally, we could also use this
transformed
space inpoly
, and provide the mesh triangulation points in transformed space!Needs tests and docs.
Type of change
Delete options that do not apply:
Checklist