Hi everyone,
I want to plot a bar chart an array that starts from index 0. when I use plot()
it works fine but when I use bar()
it gives this error.
How can I plot the bar chart?
Thanks for any help!
using JuMP, StatsPlots;
bar(JuMP.value.(S))
ArgumentError: offset arrays are not supported but got an array with index other than 1
Stacktrace:
[1] require_one_based_indexing at .\abstractarray.jl:89 [inlined]
[2] diff(::OffsetArrays.OffsetArray{Int64,1,Array{Int64,1}}; dims::Int64) at .\multidimensional.jl:826
[3] diff(::OffsetArrays.OffsetArray{Int64,1,Array{Int64,1}}) at .\multidimensional.jl:793
[4] macro expansion at C:\Users\Morteza\.julia\packages\Plots\JKY3H\src\recipes.jl:377 [inlined]
[5] apply_recipe(::RecipesPipeline.DefaultsDict, ::Type{Val{:bar}}, ::OffsetArrays.IdOffsetRange{Int64,Base.OneTo{Int64}}, ::OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}}, ::Nothing) at C:\Users\Morteza\.julia\packages\RecipesBase\jcXIg\src\RecipesBase.jl:281
[6] _process_seriesrecipe(::Plots.Plot{Plots.GRBackend}, ::RecipesPipeline.DefaultsDict) at C:\Users\Morteza\.julia\packages\RecipesPipeline\5b2IP\src\series_recipe.jl:48
[7] _process_seriesrecipes!(::Plots.Plot{Plots.GRBackend}, ::Array{Dict{Symbol,Any},1}) at C:\Users\Morteza\.julia\packages\RecipesPipeline\5b2IP\src\series_recipe.jl:25
[8] recipe_pipeline!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{JuMP.Containers.DenseAxisArray{Float64,2,Tuple{UnitRange{Int64},Base.OneTo{Int64}},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}}) at C:\Users\Morteza\.julia\packages\RecipesPipeline\5b2IP\src\RecipesPipeline.jl:95
[9] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{JuMP.Containers.DenseAxisArray{Float64,2,Tuple{UnitRange{Int64},Base.OneTo{Int64}},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}}) at C:\Users\Morteza\.julia\packages\Plots\JKY3H\src\plot.jl:167
[10] plot(::JuMP.Containers.DenseAxisArray{Float64,2,Tuple{UnitRange{Int64},Base.OneTo{Int64}},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}; kw::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:seriestype,),Tuple{Symbol}}}) at C:\Users\Morteza\.julia\packages\Plots\JKY3H\src\plot.jl:57
[11] #bar#350 at C:\Users\Morteza\.julia\packages\RecipesBase\jcXIg\src\RecipesBase.jl:402 [inlined]
[12] bar(::JuMP.Containers.DenseAxisArray{Float64,2,Tuple{UnitRange{Int64},Base.OneTo{Int64}},Tuple{Dict{Int64,Int64},Dict{Int64,Int64}}}) at C:\Users\Morteza\.julia\packages\RecipesBase\jcXIg\src\RecipesBase.jl:402
[13] top-level scope at In[469]:1