Closed timholy closed 3 years ago
The problem turns out to stem from me supplying an empty string as the default title. Debugging output in AbstractPlotting
's laxis.jl
, compute_protrusions
, yields
title = ""
titlegap = 10.0f0
titlet = Text{...}
boundingbox(titlet) = GeometryBasics.HyperRectangle{3, Float32}(Float32[NaN, NaN, NaN], Float32[NaN, NaN, NaN])
I can fix this in AbstractPlotting with
diff --git a/src/makielayout/lobjects/laxis.jl b/src/makielayout/lobjects/laxis.jl
index 2643bba..bc22d72 100644
--- a/src/makielayout/lobjects/laxis.jl
+++ b/src/makielayout/lobjects/laxis.jl
@@ -265,7 +265,9 @@ function LAxis(parent::Scene; bbox = nothing, kwargs...)
else
boundingbox(titlet).widths[2] + titlegap
end
- top += titlespace
+ if isfinite(titlespace)
+ top += titlespace
+ end
if yaxisposition == :left
left = yaxisprotrusion
but I am unsure of whether this is the right fix. And it doesn't fix all errors, later I get
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
[1] _empty_reduce_error()
@ Base ./reduce.jl:299
[2] mapreduce_empty(f::Function, op::Function, T::Type)
@ Base ./reduce.jl:342
[3] reduce_empty(op::Base.MappingRF{AbstractPlotting.var"#557#571"{Float64}, typeof(max)}, #unused#::Type{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}})
@ Base ./reduce.jl:329
[4] reduce_empty_iter
@ ./reduce.jl:355 [inlined]
[5] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}}, ItrEltype::Base.HasEltype)
@ Base ./reduce.jl:351
[6] _mapreduce(f::AbstractPlotting.var"#557#571"{Float64}, op::typeof(max), #unused#::IndexLinear, A::Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}})
@ Base ./reduce.jl:400
[7] _mapreduce_dim
@ ./reducedim.jl:318 [inlined]
[8] #mapreduce#656
@ ./reducedim.jl:310 [inlined]
[9] mapreduce
@ ./reducedim.jl:310 [inlined]
[10] #_maximum#674
@ ./reducedim.jl:875 [inlined]
[11] _maximum
@ ./reducedim.jl:875 [inlined]
[12] #maximum#672
@ ./reducedim.jl:871 [inlined]
[13] maximum
@ ./reducedim.jl:871 [inlined]
[14] #556
@ ~/.julia/dev/AbstractPlotting/src/layouting/layouting.jl:111 [inlined]
[15] iterate
@ ./generator.jl:47 [inlined]
[16] _collect(c::Vector{Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}}}, itr::Base.Generator{Vector{Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}}}, AbstractPlotting.var"#556#570"{Float64}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:699
[17] collect_similar
@ ./array.jl:628 [inlined]
[18] map
@ ./abstractarray.jl:2238 [inlined]
[19] glyph_positions(str::String, font_per_char::Base.Generator{String, AbstractPlotting.var"#544#545"{FreeTypeAbstraction.FTFont}}, fontscale_px::Base.Generator{String, AbstractPlotting.var"#542#543"{Float32}}, halign::Float32, valign::Float32, lineheight_factor::Float64, justification::Float64)
@ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/layouting/layouting.jl:110
[20] layout_text(string::String, startpos::GeometryBasics.Point{2, Float32}, textsize::Float32, font::FreeTypeAbstraction.FTFont, align::GeometryBasics.Vec{2, Float32}, rotation::AbstractPlotting.Quaternionf0, model::StaticArrays.SMatrix{4, 4, Float32, 16}, justification::Float64, lineheight::Float64)
@ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/layouting/layouting.jl:55
[21] to_gl_text(string::String, startpos::GeometryBasics.Point{2, Float32}, textsize::Float32, font::FreeTypeAbstraction.FTFont, aoffsetvec::GeometryBasics.Vec{2, Float32}, rot::AbstractPlotting.Quaternionf0, model::StaticArrays.SMatrix{4, 4, Float32, 16}, j::Float64, l::Float64)
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:268
[22] (::GLMakie.var"#106#111"{Text{...}})(str::String, pos::GeometryBasics.Point{2, Float32}, tsize::Float32, font::FreeTypeAbstraction.FTFont, align::GeometryBasics.Vec{2, Float32}, rotation::AbstractPlotting.Quaternionf0, model::StaticArrays.SMatrix{4, 4, Float32, 16}, j::Float64, l::Float64)
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:288
[23] lift(::Function, ::Observables.Observable{String}, ::Observables.Observable{GeometryBasics.Point{2, Float32}}, ::Vararg{Any, N} where N)
@ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/interaction/nodes.jl:15
[24] (::GLMakie.var"#105#110"{Text{...}})(gl_attributes::Dict{Symbol, Any})
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:285
[25] (::GLMakie.var"#69#75"{GLMakie.var"#105#110"{Text{...}}, GLMakie.Screen, AbstractPlotting.Scene, Text{...}})()
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:75
[26] get!(default::GLMakie.var"#69#75"{GLMakie.var"#105#110"{Text{...}}, GLMakie.Screen, AbstractPlotting.Scene, Text{...}}, h::Dict{UInt64, GLMakie.GLAbstraction.RenderObject}, key::UInt64)
@ Base ./dict.jl:465
[27] cached_robj!(robj_func::GLMakie.var"#105#110"{Text{...}}, screen::GLMakie.Screen, scene::AbstractPlotting.Scene, x::Text{...})
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:51
[28] draw_atomic(screen::GLMakie.Screen, scene::AbstractPlotting.Scene, x::Text{...})
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:282
[29] insert!(screen::GLMakie.Screen, scene::AbstractPlotting.Scene, x::AbstractPlotting.Combined)
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:172
[30] insertplots!(screen::GLMakie.Screen, scene::AbstractPlotting.Scene)
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/screen.jl:54
[31] backend_display(screen::GLMakie.Screen, scene::AbstractPlotting.Scene)
@ GLMakie ~/.julia/packages/GLMakie/Pway1/src/screen.jl:124
[32] backend_display
@ ~/.julia/packages/GLMakie/Pway1/src/gl_backend.jl:59 [inlined]
[33] display(d::AbstractPlotting.PlotDisplay, scene::AbstractPlotting.Scene)
@ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/display.jl:45
[34] display(x::Any)
@ Base.Multimedia ./multimedia.jl:328
[35] #invokelatest#2
@ ./essentials.jl:709 [inlined]
[36] invokelatest
@ ./essentials.jl:708 [inlined]
[37] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:246
[38] (::REPL.var"#40#41"{REPL.LineEditREPL, Tuple{AbstractPlotting.Scene, Bool}, Bool, Bool})(io::Any)
@ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:230
[39] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:461
[40] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:228
[41] (::REPL.var"#do_respond#61"{Bool, Bool, REPL.var"#72#82"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
@ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:797
[42] #invokelatest#2
@ ./essentials.jl:709 [inlined]
[43] invokelatest
@ ./essentials.jl:708 [inlined]
[44] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2435
[45] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1124
[46] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL ./task.jl:395
I think the base problem is that AbstractPlotting can't deal with certain empty plot types, one of them being text. It's a more annoying problem to fix than it looks like on the surface and because most graphs don't need empty plots it hasn't been dealt with carefully. I've made a couple issues about it over the last year.. That MakieLayout fails when text has an ill defined size is only one side effect
What about making boundingbox
return something of zero size in this case? Anything wrong with that?
There is a case to be made that an empty string should have a height but not a width, because the height reserved for a string depends not on the characters but font and fontsize. So I think this needs to be fixed at the string object (I have other fixes for strings still waiting in PRs that need GLMakie fixes first..) The other error you saw stems from later assumptions that strings are never empty, these also need to be fixed. It's also the reason why you get errors if you don't have any ticks on one dimension (I think the annotations or linesegments are not allowed to be empty).
@SimonDanisch this would be another good starting point for lower-level fixes, I think the AbstractPlotting specific broadcast mechanism needs to have its logic fixed to deal with zero element arguments.
Thanks so much!
I'm showing this error on 1.6, but I get it on 1.5 too. Any ideas where to fix? I spent about 15 minutes looking at it but
alignedbboxobservable!
andalign_to_bbox!
are not tiny functions.The demo essentially comes from the docs, http://makie.juliaplots.org/stable/makielayout/tutorial.html.
Package versions: