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

[BUG] heatmap broken for OffsetArray #4623

Open
simeonschaub opened this issue Jan 7, 2023 · 1 comment
Open

[BUG] heatmap broken for OffsetArray #4623

simeonschaub opened this issue Jan 7, 2023 · 1 comment
Labels

Comments

@simeonschaub
Copy link
Contributor

Details

julia> using Plots, OffsetArrays

julia> heatmap(OffsetMatrix(rand(11, 11), -5:5, -5:5))
ERROR: BoundsError: attempt to access 11-element OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}} with indices -5:5 at index [11]
Stacktrace:
  [1] throw_boundserror(A::OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}}, I::Tuple{Int64})
    @ Base ./abstractarray.jl:703
  [2] checkbounds
    @ ./abstractarray.jl:668 [inlined]
  [3] getindex
    @ ~/.julia/packages/OffsetArrays/WvkHl/src/axes.jl:224 [inlined]
  [4] __heatmap_edges(v::OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}}, isedges::Bool, ispolar::Bool)
    @ Plots ~/.julia/dev/Plots/src/utils.jl:242
  [5] _heatmap_edges(#unused#::Val{true}, v::OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}}, #unused#::Symbol, isedges::Bool, ispolar::Bool)
    @ Plots ~/.julia/dev/Plots/src/utils.jl:246
  [6] heatmap_edges(v::OffsetArrays.IdOffsetRange{Int64, Base.OneTo{Int64}}, scale::Symbol, isedges::Bool, ispolar::Bool) (repeats 2 times)
    @ Plots ~/.julia/dev/Plots/src/utils.jl:260
  [7] expand_extrema!(sp::Plots.Subplot{Plots.GRBackend}, plotattributes::RecipesPipeline.DefaultsDict)
    @ Plots ~/.julia/dev/Plots/src/axes.jl:512
  [8] _expand_subplot_extrema(sp::Plots.Subplot{Plots.GRBackend}, plotattributes::RecipesPipeline.DefaultsDict, st::Symbol)
    @ Plots ~/.julia/dev/Plots/src/pipeline.jl:425
  [9] add_series!(plt::Plots.Plot{Plots.GRBackend}, plotattributes::RecipesPipeline.DefaultsDict)
    @ Plots ~/.julia/dev/Plots/src/pipeline.jl:368
 [10] _process_seriesrecipe(plt::Any, plotattributes::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/XxUHt/src/series_recipe.jl:46
 [11] _process_seriesrecipes!(plt::Any, kw_list::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/XxUHt/src/series_recipe.jl:27
 [12] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/XxUHt/src/RecipesPipeline.jl:99
 [13] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots ~/.julia/dev/Plots/src/plot.jl:223
 [14] plot(args::Any; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots ~/.julia/dev/Plots/src/plot.jl:102
 [15] heatmap(::Any, ::Vararg{Any}; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots ~/.julia/packages/RecipesBase/eU0hg/src/RecipesBase.jl:427
 [16] heatmap(::Any, ::Vararg{Any})
    @ Plots ~/.julia/packages/RecipesBase/eU0hg/src/RecipesBase.jl:427
 [17] top-level scope
    @ REPL[16]:1

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: v1.38.0-dev
Backend version (]st -m <backend(s)>): GR v0.71.3

Output of versioninfo():

Julia Version 1.8.4
Commit 00177ebc4fc (2022-12-23 21:32 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 PRO 4750U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver2)
  Threads: 1 on 16 virtual cores
@icarosadero
Copy link

Ran into the same problem, doing this before passing to heatmap worked:

# A is the OffsetMatrix

A_matrix = Matrix(collect(A))

heatmap(A_matrix)

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

No branches or pull requests

2 participants