Skip to content
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

groupedbar fails to add error bars with plotly backend #496

Open
drelatgithub opened this issue Apr 21, 2022 · 3 comments
Open

groupedbar fails to add error bars with plotly backend #496

drelatgithub opened this issue Apr 21, 2022 · 3 comments

Comments

@drelatgithub
Copy link

I want to add error bars to a grouped bar chart using groupedbar function using the following line.

groupedbar(rand(3,2); yerror=rand(3,2))

When I use the gr() backend, things work okay, as shown in the screenshot.

image

However, if I use the plotly() backend, an error is displayed and no plot is produced.

Error showing value of type Plots.Plot{Plots.PlotlyBackend}:
ERROR: BoundsError: attempt to access 1-element Vector{Int64} at index [2:3]
Stacktrace:
  [1] throw_boundserror(A::Vector{Int64}, I::Tuple{UnitRange{Int64}})
    @ Base .\abstractarray.jl:691
  [2] checkbounds
    @ .\abstractarray.jl:656 [inlined]
  [3] getindex(A::Vector{Int64}, I::UnitRange{Int64})
    @ Base .\array.jl:867
  [4] plotly_series_segments(series::Plots.Series, plotattributes_base::Dict{Symbol, Any}, x::Vector{Float64}, y::Vector{Float64}, z::Nothing, clims::Tuple{Float64, Float64})
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:954
  [5] plotly_series(plt::Plots.Plot{Plots.PlotlyBackend}, series::Plots.Series)
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:606
  [6] #369
    @ .\array.jl:0 [inlined]
  [7] MappingRF
    @ .\reduce.jl:95 [inlined]
  [8] _foldl_impl(op::Base.MappingRF{Plots.var"#369#370"{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#244
    @ .\reduce.jl:162 [inlined]
 [12] mapfoldl
    @ .\reduce.jl:162 [inlined]
 [13] #mapreduce#248
    @ .\reduce.jl:289 [inlined]
 [14] mapreduce
    @ .\reduce.jl:289 [inlined]
 [15] #reduce#250
    @ .\reduce.jl:458 [inlined]
 [16] reduce
    @ .\reduce.jl:458 [inlined]
 [17] plotly_series
    @ C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1037 [inlined]
 [18] plotly_series_json(plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1041
 [19] js_body
    @ C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1106 [inlined]
 [20] plotly_html_body(plt::Plots.Plot{Plots.PlotlyBackend}, style::Nothing)
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1094
 [21] plotly_html_body
    @ C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1068 [inlined]
 [22] html_body
    @ C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1046 [inlined]
 [23] #standalone_html#397
    @ C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\web.jl:10 [inlined]
 [24] write_temp_html(plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\web.jl:43
 [25] standalone_html_window(plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\web.jl:57
 [26] _display
    @ C:\Users\█████\.julia\packages\Plots\8ouqB\src\backends\plotly.jl:1130 [inlined]
 [27] display(#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.PlotlyBackend})
    @ Plots C:\Users\█████\.julia\packages\Plots\8ouqB\src\output.jl:148
 [28] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:328
 [29] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [30] invokelatest
    @ .\essentials.jl:714 [inlined]
 [31] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:293
 [32] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:277
 [33] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:510
 [34] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:275
 [35] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:846
 [36] #invokelatest#2
    @ .\essentials.jl:716 [inlined]
 [37] invokelatest
    @ .\essentials.jl:714 [inlined]
 [38] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\LineEdit.jl:2493
 [39] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\█████\AppData\Local\Programs\Julia-1.7.2\share\julia\stdlib\v1.7\REPL\src\REPL.jl:1232
 [40] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:423

Is it a bug, or is there anything I should do to make it work? Thank you!

Julia version 1.7.2
StatsPlots version 0.14.33

@drelatgithub
Copy link
Author

I just found a similar issue #439, where groupedbar fails with plotly backend. However, the errors reported are different, and I cannot reproduce the error in #439, so I don't think this is a duplicate.

@sethaxen
Copy link
Member

I can confirm I'm seeing this error as well. @BeastyBlacksmith do you have any idea why this error might be backend-specific?

@BeastyBlacksmith
Copy link
Member

BeastyBlacksmith commented May 25, 2022

It seems this comes from groupedbar setting a fillrange for the yerror:

julia> groupedbar(rand(3,1); yerror=rand(3,1))[1][3][:fillrange]
1-element Vector{Int64}:
 0

which doesn't make too much sense and is not handled in the plotly backend.

Compare with bar:

julia> bar(rand(3,1); yerror=rand(3,1))[1][3][:fillrange] # returns nothing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants