rafaqz / DimensionalData.jl

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

More general treatment of dimensions when plotting #524

Closed tomchor closed 12 months ago

tomchor commented 1 year ago

As discussed in https://github.com/rafaqz/Rasters.jl/issues/492, it would be nice to be able to choose what dimensions go in which axis when plotting something. At the moment DD only deals with dimensions X, Y, and Z, and we may get an error when a dimension that's called something different is part of a DimArray that's being plotted. In many fields the axis names can be different, thus the flexibility of choosing each axis' dimension is very useful in general. While one can always rename the axis, this is not always feasible (there's more details as to why here).

One idea suggested by @rafaqz is to add a dims keyword that would rename the axis accordingly (to X, Y or Z) behind the scenes. It would work like:

heatmap(DA; dims=(X=:fX, Y=:fY))

Another idea is to modify the code to plot the axes without any renaming, since plotting the data using the DimArray's actual dimension names is more informative. Then a possible user interface would be the same as the one already used by heatmap (and similar to what python-xarray uses, for example). As an examle, a DimArray with dimensions x1 and x2 can be plotted as

heatmap(DA, x=:x1, y=:x2)

cc @rafaqz

PS.: I found an old issue of mine that also discussed this: https://github.com/rafaqz/DimensionalData.jl/issues/432

rafaqz commented 1 year ago

Oh right we should have left the old one open 😂