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

Plot of one dimensional DimArray ignores the lookup values of the dimensions #714

Closed felixcremer closed 3 weeks ago

felixcremer commented 1 month ago

When I plot a one-dimensional Array the label is derived from the dimension but the lookup values are not used and the plot axis is from one to length(dim). For a two dimensional array it works as expected.

nx = X(reverse(Float32[75.0, 72.5, 70.0, 67.5, 65.0, 62.5, 60.0, 57.5, 55.0, 52.5, 50.0, 47.5, 45.0, 42.5, 40.0, 37.5, 35.0, 32.5, 30.0, 27.5, 25.0, 22.5, 20.0, 17.5, 15.0]))
ny = Y(reverse(Float32[75.0, 72.5, 70.0, 67.5, 65.0, 62.5, 60.0, 57.5, 55.0, 52.5, 50.0, 47.5, 45.0, 42.5, 40.0, 37.5, 35.0, 32.5, 30.0, 27.5, 25.0, 22.5, 20.0, 17.5, 15.0]))

narr = DimArray(rand(25,25), (ny, nx))
plot(narr) # works as expected.
nsingle = DimArray(rand(25), ny)
plot(nsingle) # Would have expected that the Axis is 15 to 75 
rafaqz commented 1 month ago

Looks like we just forgot to pass the xs variable to Makie.convert_arguments

felixcremer commented 1 month ago

Yes, that works. I will prepare a PR.