-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
Accessing created Blocks/Plots for SpecApi objects #4354
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(fig)
|
…ie.jl into sd/advanced-specapi
Some Benchmarks: using WGLMakie, Bonito
import Makie.SpecApi as S
function to_spec(data)
axes = map(enumerate(data)) do (i, data)
S.Axis(plots=[S.Heatmap(data)], title="Axis: $(i)")
end
return S.GridLayout(permutedims(axes))
end
data = [rand(Float32, 10, 10) for i in 1:3]
x = Observable(to_spec(data[1:1]))
f, ax = plot(x)
display(f)
msgs1, msg1 = Bonito.collect_messages() do
x[] = to_spec(data[1:3])
end;
msgs2, msg2 = Bonito.collect_messages() do
x[] = to_spec(data[1:1])
end;
msgs3, msg3 = Bonito.collect_messages() do
x[] = to_spec(data[1:3])
end;
msgs4, msg4 = Bonito.collect_messages() do
x[] = to_spec(reverse(data[1:3]))
end; PR
Master
The big improvement is obviously, when we go from 1 -> 3 axes that have been re-created previously. |
…ie.jl into sd/advanced-specapi
Another Benchmark for swapping axes: using WGLMakie, Bonito, BenchmarkTools
import Makie.SpecApi as S
WGLMakie.activate!()
ax1 = S.Axis(; title="Title 1")
ax2 = S.Axis(; title="Title 2")
ax3 = S.Axis(; title="Title 3")
axis = [ax1, ax2, ax3]
gl = S.GridLayout(axis)
fig, _, pl = plot(gl)
display(fig)
msgs, msg = Bonito.collect_messages() do
pl[1] = S.GridLayout(reverse!(axis))
end
@btime pl[1] = S.GridLayout(reverse!(axis)) PR
Master
|
This adds a virtual
then
field to the specapi objects to interact with the created axis (plot/gridlayout?) object:The problem is, that we need to clean up any changes for when we re-use axes, and then re-apply the
then
functions.Right now, any observable
ObserverFunction
needs to be returned, so e.g. twoon
invocations need to be done like this:linkaxis!
is also supported, since we just clear the axis links when re-using any axis, so one can do:It would be nice if we could make this stricter, ideally it would be impossible to leak any mutation from
then
.But I'm not sure how we could do that, without making the API a pain to use or much harder to implement.
I'm happy to hear alternative approaches for how to register e.g. interactions with axis objects etc.