JuliaPlots / PlotlyJS.jl

Julia library for plotting with plotly.js
Other
418 stars 77 forks source link

BoundsError: attempt to access 199-element Vector{Float64} at index [1:200] #426

Open schlichtanders opened 2 years ago

schlichtanders commented 2 years ago

Describe the bug In OnlineStats.jl there is an example about HeatMap which throws an error when I activate plotlyjs

using OnlineStats
using Plots
plotlyjs()   # without ploytljs(), e.g. without anything, or with gr() everything works

xy = zip(randn(10^6), randn(10^6))
o = fit!(HeatMap(-5:.1:5, -5:.1:5), xy)
plot(o)

xy = zip(1 .+ randn(10^6) ./ 10, randn(10^6))
o = HeatMap(xy)
plot(o, marginals=false)
plot(o)

it throws

BoundsError: attempt to access 199-element Vector{Float64} at index [1:200]

Stacktrace:
  [1] throw_boundserror(A::Vector{Float64}, I::Tuple{UnitRange{Int64}})
    @ Base ./abstractarray.jl:651
  [2] checkbounds
    @ ./abstractarray.jl:616 [inlined]
  [3] getindex(A::Vector{Float64}, I::UnitRange{Int64})
    @ Base ./array.jl:807
  [4] plotly_series_segments(series::Plots.Series, plotattributes_base::Dict{Symbol, Any}, x::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, y::Vector{Float64}, z::Nothing, clims::Tuple{Float64, Float64})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:873
  [5] plotly_series(plt::Plots.Plot{Plots.PlotlyBackend}, series::Plots.Series)
    @ Plots ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:606
  [6] #387
    @ ./array.jl:0 [inlined]
  [7] MappingRF
    @ ./reduce.jl:93 [inlined]
  [8] _foldl_impl(op::Base.MappingRF{Plots.var"#387#388"{Plots.Plot{Plots.PlotlyBackend}}, Base.BottomRF{typeof(vcat)}}, init::Base._InitialValue, itr::Vector{Plots.Series})
    @ Base ./reduce.jl:62
  [9] foldl_impl
    @ ./reduce.jl:48 [inlined]
 [10] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
 [11] #mapfoldl#214
    @ ./reduce.jl:160 [inlined]
 [12] mapfoldl
    @ ./reduce.jl:160 [inlined]
 [13] #mapreduce#218
    @ ./reduce.jl:287 [inlined]
 [14] mapreduce
    @ ./reduce.jl:287 [inlined]
 [15] #reduce#220
    @ ./reduce.jl:456 [inlined]
 [16] reduce
    @ ./reduce.jl:456 [inlined]
 [17] plotly_series
    @ ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1034 [inlined]
 [18] plotly_series_json(plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1038
 [19] js_body
    @ ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1103 [inlined]
 [20] plotly_html_body(plt::Plots.Plot{Plots.PlotlyBackend}, style::Nothing)
    @ Plots ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1091
 [21] plotly_html_body
    @ ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1065 [inlined]
 [22] html_body
    @ ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1043 [inlined]
 [23] embeddable_html
    @ ~/.julia/packages/Plots/qbc7U/src/backends/web.jl:26 [inlined]
 [24] _show(io::IOBuffer, #unused#::MIME{Symbol("text/html")}, plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/backends/plotly.jl:1123
 [25] show(io::IOBuffer, m::MIME{Symbol("text/html")}, plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/output.jl:213
 [26] sprint(::Function, ::MIME{Symbol("text/html")}, ::Vararg{Any, N} where N; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:105
 [27] sprint
    @ ./strings/io.jl:101 [inlined]
 [28] _ijulia_display_dict(plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/ijulia.jl:50
 [29] display_dict(plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/init.jl:93
 [30] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [31] invokelatest
    @ ./essentials.jl:706 [inlined]
 [32] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/execute_request.jl:112
 [33] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [34] invokelatest
    @ ./essentials.jl:706 [inlined]
 [35] eventloop(socket::ZMQ.Socket)
    @ IJulia ~/.julia/packages/IJulia/e8kqU/src/eventloop.jl:8
 [36] (::IJulia.var"#15#18")()
    @ IJulia ./task.jl:411

Version info

Please provide the following:

  1. output of julia command versioninfo()

    julia> versioninfo()
    Julia Version 1.6.1
    Commit 6aaedecc44 (2021-04-23 05:59 UTC)
    Platform Info:
    OS: Linux (x86_64-pc-linux-gnu)
    CPU: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
    WORD_SIZE: 64
    LIBM: libopenlibm
    LLVM: libLLVM-11.0.1 (ORCJIT, icelake-client)
  2. Output running the following in Julia 0.7 or greater: using Pkg; pkg"status" (if you are on Julia 0.6 or earlier run Pkg.status())

    julia> using Pkg; pkg"status"
      Status `~/.julia/environments/v1.6/Project.toml`
    [a15396b6] OnlineStats v1.5.13
    [925886fa] OnlineStatsBase v1.4.9
    [f0f68f2c] PlotlyJS v0.18.8
    [91a5bcdd] Plots v1.25.0
    ...