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
LineAxis
: add arbitrary {x,y}labelrotation
#2478
Conversation
A good reference test would have two steps
|
Closes #2222 |
And it seems the |
Yeah, I think I need to add a |
For the alignements, I've reused (and renamed) the Would it be acceptable to use |
Those functions are just meant for ticklabels which have to be aligned sensibly relative to the tick marks, and this behavior should be reasonably automatic given the rotation angle. For the axis labels, an alignment of |
So I've got this simple example. julia> N = 18 # number of rotations
julia> fig, ax, _ = scatter(0:1; axis = (; xlabel = "a nice and long x label for this axis", ylabel = "a nice and long y label for this axis"))
julia> record(fig, "rot.gif") do io
for rot in LinRange(0, 2π, N)
ax.xlabelrotation[] = rot
ax.ylabelrotation[] = rot
recordframe!(io)
end
end Regarding the test I have a few questions:
|
LineAxis
: add arbitrary {x,y}
rotationLineAxis
: add arbitrary {x,y}
label rotation
LineAxis
: add arbitrary {x,y}
label rotationLineAxis
: add arbitrary {x,y}labelrotation
Ok you can see in your example how the layout does not react to the different space taken up by the rotating labels. I would make the alignment behave like |
How do I draw text bounding boxes again ? foreach(Any, fig.layout) do l
wireframe!(fig.scene, l.layoutobservables.suggestedbbox[])
end |
If the alignment is set to |
By anchor I just mean the point at which the text is plotted. This is not the same anymore as it was before your PR, it must be shifted outwards by half the boundingbox. And I think it's something like |
How can I access the axis decorations (for accessing |
Could be that this dict is just a remnant at this point, do you need it? The LineAxis just needs to communicate its protrusion value outwards, so at least the Axis shouldn't need access. Or is this just for debugging? |
I though so: Makie.jl/src/makielayout/lineaxis.jl Line 257 in 5de2b6b
|
I was mostly using it for debugging as well at the time, must have dropped out of use without me noticing. |
I doesn't seem possible to know the textlabel |
d38c918
to
c32e23b
Compare
57148c5
to
ac55e41
Compare
8cee672
to
8d9f144
Compare
I've minimized the changes and removed unrelated modifications, but the I am a bit clueless here ... |
I tried to reproduce locally using using JSServe, Markdown, WGLMakie
Page(exportable=true, offline=true)
WGLMakie.activate!()
fig, ax, plot = scatter(0:1)
Colorbar(fig[1, 2]; label = "vertical cbar")
display(fig) ERROR: TypeError: scene is undefined
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] evaljs_value(session::Session, js::JSServe.JSCode; error_on_closed::Bool, time_out::Float64)
@ JSServe ~/.julia/packages/JSServe/kIK9q/src/session.jl:238
[3] evaljs_value
@ ~/.julia/packages/JSServe/kIK9q/src/session.jl:206 [inlined]
[4] insert!(td::WGLMakie.ThreeDisplay, scene::Scene, plot::Poly{Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}})
@ WGLMakie ~/.julia/packages/WGLMakie/L5URO/src/three_plot.jl:24
[5] insert!(td::WGLMakie.Screen, scene::Scene, plot::Poly{Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}})
@ WGLMakie ~/.julia/packages/WGLMakie/L5URO/src/display.jl:173
[6] push!(scene::Scene, plot::Poly{Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}})
@ Makie [...]/Makie.jl/src/scenes.jl:409
[7] plot!(scene::Scene, P::Type{Poly{Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}}}, attributes::Attributes, input::Tuple{Observable{Vector{GeometryBasics.HyperRectangle{2, Float32}}}}, args::Observable{Tuple{Vector{GeometryBasics.HyperRectangle{2, Float32}}}})
@ Makie [...]/Makie.jl/src/interfaces.jl:422
[8] plot!(scene::Scene, P::Type{Poly}, attributes::Attributes, args::Observable{Vector{GeometryBasics.HyperRectangle{2, Float32}}}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Makie [...]/Makie.jl/src/interfaces.jl:336
[9] plot!
@ [...]/Makie.jl/src/interfaces.jl:303 [inlined]
[10] #plot!#165
@ [...]/Makie.jl/src/interfaces.jl:287 [inlined]
[11] poly!(::Scene, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:color, :visible, :inspectable), Tuple{Observable{Vector{ColorTypes.RGBA{Float64}}}, Observable{Bool}, Bool}}})
@ MakieCore [...]/Makie.jl/MakieCore/src/recipes.jl:38
[12] initialize_block!(cb::Colorbar)
@ Makie [...]/Makie.jl/src/makielayout/blocks/colorbar.jl:197
[13] _block(::Type{Colorbar}, ::Figure; bbox::Nothing, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:label, :labelrotation), Tuple{String, Int64}}})
@ Makie [...]/Makie.jl/src/makielayout/blocks.jl:408
[14] _block(::Type{Colorbar}, ::GridPosition; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:label, :labelrotation), Tuple{String, Int64}}})
@ Makie [...]/Makie.jl/src/makielayout/blocks.jl:294
[15] #_#1077
@ [...]/Makie.jl/src/makielayout/blocks.jl:279 [inlined]
[16] top-level scope
@ REPL[21]:1
[17] eval
@ ./boot.jl:368 [inlined]
[18] eval_user_input(ast::Any, backend::REPL.REPLBackend)
@ REPL ~/share/julia/stdlib/v1.8/REPL/src/REPL.jl:151
[19] repl_backend_loop(backend::REPL.REPLBackend)
@ REPL ~/share/julia/stdlib/v1.8/REPL/src/REPL.jl:247
[20] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
@ REPL ~/share/julia/stdlib/v1.8/REPL/src/REPL.jl:232
[21] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
@ REPL ~/share/julia/stdlib/v1.8/REPL/src/REPL.jl:369
[22] run_repl(repl::REPL.AbstractREPL, consumer::Any)
@ REPL ~/share/julia/stdlib/v1.8/REPL/src/REPL.jl:355
[23] (::Base.var"#967#969"{Bool, Bool, Bool})(REPL::Module)
@ Base ./client.jl:419
[24] #invokelatest#2
@ ./essentials.jl:729 [inlined]
[25] invokelatest
@ ./essentials.jl:726 [inlined]
[26] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
@ Base ./client.jl:404
[27] top-level scope
@ none:40 |
I've tried this PR against #2428, same error. |
Dropping a note to say that this |
Thank you, @t-bltg! |
Thanks for the help and the constructive comments made on this PR, I couldn't have done without (or would have written sloppy code for sure :)) ! |
Missing reference imagesFound 1 new images without existing references. |
* `LineAxis`: add arbitrary `{x,y}` rotation * add news entry * handle alignements * start adding tests * fix attribute * update position * revert un-necessary rename * trigger `calculate_protrusion` on `labelrotation` * add comments * fix flip * add tests * restore `labelalign` * enhance tests using colorbars * cleanup temporary file * temporarily revert stylistic changes and type asserts * do not use `@lift` for `ignore_equal_values` at the expense of readability * split test as `WGLMakie` bug workaround * update changelog * minor simplifications - readability Co-authored-by: Julius Krumbiegel <22495855+jkrumbiegel@users.noreply.github.com>
Fix #1187.
Fix #2222.
Description
As discussed with @jkrumbiegel on discord, add the ability to rotate axis labels:
Any comments on adding docs about this (where should this go ?) or tests (do you want static tests or new ref images maybe ?) would be appreciated.
TODO:
Type of change
Delete options that do not apply:
Checklist