Skip to content

[BUG] Assertion error total_plotarea_vertical > 0mm. Plots remains unusable afterwards #4816

@yha

Description

@yha

Details

Sometimes plot display fails with one of the assertions at
https://github.com/JuliaPlots/Plots.jl/blob/4ad4a04a176ba55e69a1263acee8bd0f3034f09a/src/layouts.jl#L342C1-L343C42
and afterwards it's impossible to display plots in the same session.

This bug is weirdly history-dependent, but I've managed to found this reproducer (note that the plot needs to be displayed twice to trigger the bug)

julia> using Plots

julia> function badplot()
           plt1 = heatmap(rand(4,4); title = "title")
           plt2 = plot(fill(NaN,4), fill(NaN,4))
           annotate!([NaN, NaN], [NaN, NaN], Plots.text.(["a", "b"], 12))

           plot(plt1, plt2)
       end
badplot (generic function with 1 method)

julia> badplot()

julia> badplot()
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: AssertionError: total_plotarea_vertical > 0mm
Stacktrace:
  [1] update_child_bboxes!(layout::Plots.GridLayout, minimum_perimeter::Vector{Measures.AbsoluteLength})
    @ Plots C:\Users\sternlab\.julia\packages\Plots\3BCH5\src\layouts.jl:343
  [2] update_child_bboxes!(layout::Plots.GridLayout)
    @ Plots C:\Users\sternlab\.julia\packages\Plots\3BCH5\src\layouts.jl:315
  [3] prepare_output(plt::Plots.Plot{Plots.GRBackend})
    @ Plots C:\Users\sternlab\.julia\packages\Plots\3BCH5\src\plot.jl:251
  [4] display(#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.GRBackend})
    @ Plots C:\Users\sternlab\.julia\packages\Plots\3BCH5\src\output.jl:168
  [5] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
  [6] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
  [7] invokelatest
    @ .\essentials.jl:813 [inlined]
  [8] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:305
  [9] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:287
 [10] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:557
 [11] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:285
 [12] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:899
 [13] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [14] invokelatest
    @ .\essentials.jl:813 [inlined]
 [15] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2647
 [16] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\sternlab\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:1300
 [17] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:514

It looks like this puts GR in a state where all subsequent calls to GR.inqtext return NaNs, which messes up all layouts.

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs
pgfplotsx
unicodeplots
inspectdr
gaston

Versions

Plots.jl version: v1.38.17 and master
Backend version (]st -m <backend(s)>): 0.72.9
Output of versioninfo():
julia> versioninfo()
Julia Version 1.9.0
Commit 8e63055292 (2023-05-07 11:25 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 16 × Intel(R) Core(TM) i7-9800X CPU @ 3.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, skylake-avx512)
Threads: 1 on 16 virtual cores

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions