rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
262 stars 38 forks source link

Dimensions of Observable(dd) are ignored in Makie 0.21 #724

Open felixcremer opened 3 weeks ago

felixcremer commented 3 weeks ago

In Makie 0.21 plotting an Observable of a DimArray ignores the Dimension information and also the Axis labels are not shown. This works with Makie 0.20 both with the current DimensionalData 0.27.3

julia> using DimensionalData

julia> dd = DimArray(rand(6,5), (X(1:6), Y(4:8)))
╭─────────────────────────╮
│ 6×5 DimArray{Float64,2} │
├─────────────────────────┴─────────────────────── dims ┐
  ↓ X Sampled{Int64} 1:6 ForwardOrdered Regular Points,
  → Y Sampled{Int64} 4:8 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────┘
 ↓ →  4          5         6          7         8
 1    0.325016   0.560859  0.993459   0.50559   0.314472
 2    0.0270105  0.080017  0.0416587  0.23208   0.209695
 3    0.0423516  0.434358  0.967477   0.209886  0.926122
 4    0.684203   0.357766  0.703951   0.729541  0.986278
 5    0.100141   0.998387  0.235898   0.935083  0.714166
 6    0.496768   0.53056   0.451351   0.698009  0.107357

julia> data = Observable{Any}(dd)
Observable{Any}([0.3250157237792046 0.5608592968803442 … 0.5055896174259253 0.3144717365406484; 0.027010510057244752 0.08001697018929188 … 0.2320796908802627 0.20969531084102178; … ; 0.10014061026245069 0.9983866156386614 … 0.9350829236154046 0.714166165853603; 0.4967683108431902 0.5305600123974606 … 0.6980092869744876 0.10735654805188433])

julia> plot(data) # I expected to get a Y axis from 4 to 8 and not 1 to 5

(@makie21) pkg> st
Status `~/.julia/environments/makie21/Project.toml`
  [0703355e] DimensionalData v0.27.3
  [e9467ef8] GLMakie v0.10.2
  [ee78f7c6] Makie v0.21.2
asinghvi17 commented 3 weeks ago

ah the observable type is probably the issue here in terms of dispatch. #720 should make this a non-issue since we would ideally not be relying on argument types at the user level...

asinghvi17 commented 3 weeks ago

Actually, maybe julia> data = Observable{AbstractDimArray}(dd) would work?

felixcremer commented 3 weeks ago

No that does not make a difference. Also just using Observable(dd) which is of type DimMatrix does nothing.

rafaqz commented 3 weeks ago

We just don't have any dispatch on Observables{<:AbstractDimArray}, basically I just forgot to add it.

felixcremer commented 3 weeks ago

But also something in Makie changed, because it used to work with Makie 0.20 to plot a DimArray even in an Observable{Any}. But Adding a dispatch on Observables{<:AbstractDimArray} should help for now.

asinghvi17 commented 3 weeks ago

I think that goes back to the expand_dimensions again :D

asinghvi17 commented 3 weeks ago

yep, see https://github.com/MakieOrg/Makie.jl/blob/b4a92427bbf71bd3e2155bf3a9fc1be18c1ee2d9/src/interfaces.jl#L138-L151

rafaqz commented 3 weeks ago

I made some comments on that PR... I'm not sure the expand_dimensions approach can do half the things we are doing currently

https://github.com/rafaqz/DimensionalData.jl/issues/720#issuecomment-2158526784

rafaqz commented 3 weeks ago

Like its probably worth doing anyway but we might still need our own method dispatch anyway for other reasons