Open yha opened 1 year ago
I have also encountered this bug. It is very frustrating! Kudos for figuring out how to reproduce it!
I am also experiencing this bug.
I'd say the easiest solution would be to error when there is any non-finite value passed to annotate!
But it would be more consistent with the usual Plots
behavior to skip only the annotations at non-finite coordinates
Btw, i do not use annotate!
and i still have this bug. So it's not as simple as a fix to annotate!
(unless it is getting called internally)
julia> using Plots
julia> plot(1:3, -(1:3), yscale=:log10, xlabel="test")
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/packages/PlotUtils/mHQ0Q/src/ticks.jl:191
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/packages/PlotUtils/mHQ0Q/src/ticks.jl:191
┌ Warning: Invalid negative or zero value -1 found at series index 1 for log10 based yscale
└ @ Plots ~/.julia/packages/Plots/rz1WP/src/utils.jl:106
julia> plot(1:3, -(1:3), yscale=:log10, xlabel="test")
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/packages/PlotUtils/mHQ0Q/src/ticks.jl:191
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 ~/.julia/packages/Plots/rz1WP/src/layouts.jl:343
[2] update_child_bboxes!(layout::Plots.GridLayout)
@ Plots ~/.julia/packages/Plots/rz1WP/src/layouts.jl:315
[3] prepare_output(plt::Plots.Plot{Plots.GRBackend})
@ Plots ~/.julia/packages/Plots/rz1WP/src/plot.jl:251
[4] display(#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.GRBackend})
@ Plots ~/.julia/packages/Plots/rz1WP/src/output.jl:168
[5] display(x::Any)
@ Base.Multimedia ./multimedia.jl:340
Got this error as well, after using twinx().
Plotting negative values in log scale causes this bug. Workaround by plotting without labels.
using Plots
plot(1:5, rand(5); yscale=:log10, xlabel="x", ylabel="y") # ok
# source of error
## ploting negetive with log sacle
pln = plot(1:5,-rand(5); yscale=:log10, xlabel="x", ylabel="y"); # <- note the ; # still ok
display(pln) # ERROR: AssertionError: total_plotarea_horizontal > 0mm
# bug:
pl = plot(1:5, rand(5); yscale=:log10, xlabel="x", ylabel="y"); # <- note the ; # still ok
# should be ok, by fails
display(pl) # ERROR: AssertionError: total_plotarea_horizontal > 0mm
# workaround
plot(1:5, rand(5); yscale=:log10) # plot without labels
plot(1:5, rand(5); yscale=:log10, xlabel="x", ylabel="y") # ok again
Julia version is v1.10.0 Plots version is v1.40.0
@AmitRotem
Plotting negative values in log scale causes this bug. Workaround by plotting without labels.
using Plots plot(1:5, rand(5); yscale=:log10, xlabel="x", ylabel="y") # ok
I'm getting the same error doing this example with pre-existing plot. I have to restart the environment to not get this error.
@j-adel I retested this in; Julia Version 1.10.5 with Plots v1.40.8
Still works for me. After trying to display negative values in log scale;
This plot(1:5, rand(5); yscale=:log10)
don't fail, but still looks bad.
The next one plot(1:5, rand(5); yscale=:log10, xlabel="x", ylabel="y")
is ok
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)
It looks like this puts GR in a state where all subsequent calls to
GR.inqtext
returnNaN
s, which messes up all layouts.Backends
This bug occurs on ( insert
x
below )Versions
Plots.jl version: v1.38.17 and master Backend version (
]st -m <backend(s)>
): 0.72.9 Output ofversioninfo()
: 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