Access to DimensionalData time axis

If I have a DimensionalData variable like

using DimensionalData
a = DimArray(rand(12), Ti(DateTime(2001):Month(1):DateTime(2001,12)))

a.data gives data but how to access the time axis (e.g. for plotting in Makie)?

It seems that

julia> dims(a, Ti)|>collect
12-element Vector{DateTime}:
 2001-01-01T00:00:00
 2001-02-01T00:00:00
 2001-03-01T00:00:00
 2001-04-01T00:00:00
 2001-05-01T00:00:00
 2001-06-01T00:00:00
 2001-07-01T00:00:00
 2001-08-01T00:00:00
 2001-09-01T00:00:00
 2001-10-01T00:00:00
 2001-11-01T00:00:00
 2001-12-01T00:00:00

does the trick.

You can also just do parent(dims(A, Ti)), which is a bit more efficient than collect.

But we should just implement recipes for Makie.jl, like there are recipes for Plots.jl.

If you use Plots.jl you can just plot(A) and it will probably do what you want.

Also, can’t resist… you can simplify your example:

a = rand(Ti(DateTime(2001):Month(1):DateTime(2001,12))
1 Like

I haven’t noticed parent(), it seems that it would be useful to reread the full documentation from time to time :-), thanks for pointing that out!

In fact I have used Plots.jl before and that’s why I did not have to access Ti axis directly and extracting Tiaxis was a new trick for me. Recipe for Makie.jl would be very nice.

Yes, I know that rand() can be used directly but I wanted just to use some data as an example.

parent is just the Base julia method to get the parent Array when it is wrapped in another object.