-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
[BUG] can't plot with default colour scale with high precision floats #4270
Comments
If that is the case (it would be better to provide the full stacktrace), the bug should be reported to |
I think OP meant the files julia> heatmap(rand(BigFloat, 200, 200))
Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: BoundsError: attempt to access 256-element Vector{Float64} at index [257]
Stacktrace:
[1] getindex
@ .\essentials.jl:13 [inlined]
[2] get(cg::PlotUtils.ContinuousColorGradient, x::BigFloat, rangescale::Tuple{Float64, Float64})
@ PlotUtils C:\Users\ngudat\.julia\packages\PlotUtils\M092a\src\colorschemes.jl:68
[3] (::PlotUtils.var"#6#7"{PlotUtils.ContinuousColorGradient})(x::BigFloat)
@ PlotUtils C:\Users\ngudat\.julia\packages\PlotUtils\M092a\src\colorschemes.jl:29
[4] iterate
@ .\generator.jl:47 [inlined]
[5] collect_to!(dest::Matrix{RGBA{BigFloat}}, itr::Base.Generator{Matrix{BigFloat}, PlotUtils.var"#6#7"{PlotUtils.ContinuousColorGradient}}, offs::Int64, st::Int64)
@ Base .\array.jl:840
[6] collect_to_with_first!(dest::Matrix{RGBA{BigFloat}}, v1::RGBA{BigFloat}, itr::Base.Generator{Matrix{BigFloat}, PlotUtils.var"#6#7"{PlotUtils.ContinuousColorGradient}}, st::Int64)
@ Base .\array.jl:818
[7] _collect(c::Matrix{BigFloat}, itr::Base.Generator{Matrix{BigFloat}, PlotUtils.var"#6#7"{PlotUtils.ContinuousColorGradient}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{2})
@ Base .\array.jl:812
[8] collect_similar
@ .\array.jl:711 [inlined]
[9] map
@ .\abstractarray.jl:3255 [inlined]
[10] get(cg::PlotUtils.ContinuousColorGradient, v::Matrix{BigFloat}, rangescale::Tuple{Float64, Float64})
@ PlotUtils C:\Users\ngudat\.julia\packages\PlotUtils\M092a\src\colorschemes.jl:29
[11] gr_draw_heatmap(series::Plots.Series, x::Vector{Float64}, y::Vector{Float64}, z::Matrix{BigFloat}, clims::Tuple{Float64, Float64})
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:1954
[12] gr_add_series(sp::Plots.Subplot{Plots.GRBackend}, series::Plots.Series)
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:1728
[13] gr_display(sp::Plots.Subplot{Plots.GRBackend}, w::Measures.AbsoluteLength, h::Measures.AbsoluteLength, vp_canvas::Plots.GRViewport{Float64})
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:956
[14] (::Plots.var"#528#529"{Int64, Int64, Plots.GRViewport{Float64}})(sp::Plots.Subplot{Plots.GRBackend})
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:680
[15] foreach(f::Plots.var"#528#529"{Int64, Int64, Plots.GRViewport{Float64}}, itr::Vector{Plots.Subplot})
@ Base .\abstractarray.jl:3067
[16] gr_display(plt::Plots.Plot{Plots.GRBackend}, dpi_factor::Int64)
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:680
[17] gr_display
@ C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:650 [inlined]
[18] #574
@ C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:2044 [inlined]
[19] withenv(::Plots.var"#574#576"{Plots.Plot{Plots.GRBackend}}, ::Pair{String, String}, ::Vararg{Pair{String}})
@ Base .\env.jl:197
[20] _display(plt::Plots.Plot{Plots.GRBackend})
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\backends\gr.jl:2043
[21] display(#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.GRBackend})
@ Plots C:\Users\ngudat\.julia\packages\Plots\nuwp4\src\output.jl:174
[22] display(x::Any)
@ Base.Multimedia .\multimedia.jl:340
[23] #invokelatest#2
@ .\essentials.jl:816 [inlined]
[24] invokelatest
@ .\essentials.jl:813 [inlined]
[25] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL C:\Users\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\REPL.jl:302
[26] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
@ REPL C:\Users\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\REPL.jl:284
[27] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL C:\Users\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\REPL.jl:551
[28] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL C:\Users\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\REPL.jl:282
[29] (::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\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\REPL.jl:893
[30] #invokelatest#2
@ .\essentials.jl:816 [inlined]
[31] invokelatest
@ .\essentials.jl:813 [inlined]
[32] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit C:\Users\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2644
[33] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL C:\Users\ngudat\AppData\Local\Programs\Julia-1.9.0-beta3\share\julia\stdlib\v1.9\REPL\src\REPL.jl:1293
[34] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL .\task.jl:514 |
@nilshg, your example doesn't error ? Xref https://discourse.julialang.org/t/display-function-returning-boundserror/93548 |
Hm, you're right - it only errors when one adds |
However OP's example errors on current |
There's an issue with the limits of the default colour scale when plotting with high precision floats (e.g. BigFloats).
Details
When plotting data that isn't Float64s but higher precision floats (like BigFloats, or ArbFloats from the ArbNumerics package), the following issue sometimes appears:
Backends
Presumably all backends, this bug originates in colorschemes.jl
Versions
Plots.jl version: 1.31.1
Backend version (
]st -m <backend(s)>
): irrelevantOutput of
versioninfo()
:Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
JULIA_ERROR_COLOR = magenta
JULIA_EDITOR = emacsclient
The text was updated successfully, but these errors were encountered: