Skip to content
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

Giving in elabels_rotation as Real throws error #68

Closed
filchristou opened this issue Mar 2, 2022 · 2 comments
Closed

Giving in elabels_rotation as Real throws error #68

filchristou opened this issue Mar 2, 2022 · 2 comments

Comments

@filchristou
Copy link
Collaborator

gc = circular_ladder_graph(5)
graphplot(gc, elabels = repr.(edges(gc)), nlabels=repr.(vertices(gc)), elabels_rotation=45)
ERROR: TypeError: in new, expected Makie.ScalarOrVector{Quaternionf}, got a value of type Makie.ScalarOrVector{Int64}
Stacktrace:
  [1] Makie.GlyphCollection(glyphs::Vector{Char}, fonts::Vector{FreeTypeAbstraction.FTFont}, origins::Vector{Point{3, Float32}}, extents::Vector{FreeTypeAbstraction.FontExtent{Float32}}, scales::Vector{Vec{2, Float32}}, rotations::Vector{Int64}, colors::Vector{ColorTypes.RGBA{Float32}}, strokecolors::Vector{ColorTypes.RGBA{Float32}}, strokewidths::Vector{Int64})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/types.jl:342
  [2] glyph_collection(str::String, font_per_char::Base.Generator{String, Makie.var"#662#663"{FreeTypeAbstraction.FTFont}}, fontscale_px::Base.Generator{String, Makie.var"#660#661"{Float32}}, halign::Symbol, valign::Symbol, lineheight_factor::Float64, justification::MakieCore.Automatic, rotation::Int64, color::ColorTypes.RGBA{Float32}, strokecolor::ColorTypes.RGBA{Float32}, strokewidth::Int64)
    @ Makie ~/.julia/packages/Makie/gQOQF/src/layouting/layouting.jl:213
  [3] layout_text
    @ ~/.julia/packages/Makie/gQOQF/src/layouting/layouting.jl:53 [inlined]
  [4] (::Makie.var"#981#983"{Vector{Makie.GlyphCollection}})(str::String, ts::Float32, f::FreeTypeAbstraction.FTFont, al::Tuple{Symbol, Symbol}, rot::Int64, jus::MakieCore.Automatic, lh::Float64, col::ColorTypes.RGBA{Float32}, scol::ColorTypes.RGBA{Float32}, swi::Int64)
    @ Makie ~/.julia/packages/Makie/gQOQF/src/basic_recipes/text.jl:47
  [5] broadcast_foreach(::Function, ::Vector{String}, ::Vararg{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/utilities/utilities.jl:176
  [6] (::Makie.var"#980#982"{Observable{Any}, Observable{Any}, Observable{Vector{Makie.GlyphCollection}}})(str::Vector{String}, ts::Int64, pos::Vector{Point{2, Float32}}, f::String, al::Tuple{Symbol, Symbol}, rot::Int64, jus::MakieCore.Automatic, lh::Float64, col::Symbol, scol::Tuple{Symbol, Float64}, swi::Int64)
    @ Makie ~/.julia/packages/Makie/gQOQF/src/basic_recipes/text.jl:45
  [7] (::Observables.OnUpdate{Makie.var"#980#982"{Observable{Any}, Observable{Any}, Observable{Vector{Makie.GlyphCollection}}}, Tuple{Observable{Vector{String}}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}, Observable{Any}}})(#unused#::Vector{String})
    @ Observables ~/.julia/packages/Observables/OFj0u/src/Observables.jl:334
  [8] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
  [9] invokelatest
    @ ./essentials.jl:714 [inlined]
 [10] notify(observable::Observable{Vector{String}})
    @ Observables ~/.julia/packages/Observables/OFj0u/src/Observables.jl:88
 [11] plot!(plot::MakieCore.Text{Tuple{Vector{String}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/basic_recipes/text.jl:56
 [12] plot!(scene::Combined{GraphMakie.graphplot, Tuple{SimpleGraph{Int64}}}, P::Type{MakieCore.Text{Tuple{Vector{String}}}}, attributes::Attributes, input::Tuple{Observable{Any}}, args::Observable{Tuple{Vector{String}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:456
 [13] plot!(scene::Combined{GraphMakie.graphplot, Tuple{SimpleGraph{Int64}}}, P::Type{MakieCore.Text}, attributes::Attributes, args::Observable{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:339
 [14] plot!
    @ ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:308 [inlined]
 [15] #plot!#157
    @ ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:291 [inlined]
 [16] text!(::Combined{GraphMakie.graphplot, Tuple{SimpleGraph{Int64}}}, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Observable, NTuple{6, Symbol}, NamedTuple{(:position, :rotation, :offset, :align, :color, :textsize), Tuple{Observable{Vector{Point{2, Float32}}}, Observable{Int64}, Observable{Vector{Point{2, Float32}}}, Observable{Any}, Observable{Any}, Observable{Any}}}})
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [17] plot!(gp::Combined{GraphMakie.graphplot, Tuple{SimpleGraph{Int64}}})
    @ GraphMakie ~/.julia/packages/GraphMakie/ya5tg/src/recipes.jl:309
 [18] plot!(scene::Scene, P::Type{Combined{GraphMakie.graphplot, Tuple{SimpleGraph{Int64}}}}, attributes::Attributes, input::Tuple{Observable{SimpleGraph{Int64}}}, args::Observable{Tuple{SimpleGraph{Int64}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:428
 [19] plot!(scene::Scene, P::Type{Combined{GraphMakie.graphplot}}, attributes::Attributes, args::SimpleGraph{Int64}; kw_attributes::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:show_axis,), Tuple{Bool}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:339
 [20] plot(P::Type{Combined{GraphMakie.graphplot}}, args::SimpleGraph{Int64}; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, kw_attributes::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:elabels, :nlabels, :elabels_rotation), Tuple{Vector{String}, Vector{String}, Int64}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/figureplotting.jl:28
 [21] #graphplot#13
    @ ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:31 [inlined]
 [22] top-level scope
    @ REPL[16]:1

I would expect from here that such input should be handled.
A workaround would be to substitute rot = $(gp.elabels_rotation) with something like rot = Vector{Float32}(fill($(gp.elabels_rotation), ne(gp.graph[])). This would also encourage to have elabels_opposite being applied to all input elabels_rotation rather just give out a fixed rotation based on the vertices position, as mentioned on #67

Passing in elabels_opposite will not influence the result. In my opinion this shouldn't be the case and I would propose to move the relative for loop outside the if-else statement. But this would mean that the "opposite" applies to the rotations handled in and it doesn't give out a particular opposite angle as it is now.

From the other side maybe using Vector{Float32} is not very generic ?

@hexaeder
Copy link
Collaborator

hexaeder commented Mar 2, 2022

Would be interesting to see if this worked on Makie v0.15. I am pretty sure I've tested this before 🤔
However, this is just another hint that we really need to get some reference testing going #22

@filchristou
Copy link
Collaborator Author

The 2 lines of code now seem to produce the desired image:
image
So I assume it's safe to close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants