# Makie does not accept Vector{DataTime} types？

**URL:** <https://discourse.julialang.org/t/makie-does-not-accept-vector-datatime-types/113218>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [April 19, 2024, 4:04am UTC](https://discourse.julialang.org/t/makie-does-not-accept-vector-datatime-types/113218 "2024-04-19T04:04:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dk-zen](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dk-zen](https://discourse.julialang.org/u/dk-zen)\
**Post date:** [April 19, 2024, 4:04am UTC](https://discourse.julialang.org/t/makie-does-not-accept-vector-datatime-types/113218/1 "2024-04-19T04:04:39Z")

</div>

Why doesn’t Makie accept DataTime type, DataTime type is often used.

```julia
julia> typeof(e)
Vector{Float64} (alias for Array{Float64, 1})

julia> typeof(time)
Vector{DateTime} (alias for Array{DateTime, 1})

julia> lines(time, e)
ERROR: `Makie.convert_arguments` for the plot type Lines and its conversion trait PointBased() was unsuccessful.

The signature that could not be converted was:
::Vector{DateTime}, ::Vector{Float32}

Makie needs to convert all plot input arguments to types that can be consumed by the backends (typically Arrays with Float32 elements).
You can define a method for `Makie.convert_arguments` (a type recipe) for these types or their supertypes to make this set of arguments convertible (See http://docs.makie.org/stable/documentation/recipes/index.html).    

Alternatively, you can define `Makie.convert_single_argument` for single arguments which have types that are unknown to Makie but which can be converted to known types and fed back to the conversion pipeline.

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [April 19, 2024, 5:11am UTC](https://discourse.julialang.org/t/makie-does-not-accept-vector-datatime-types/113218/2 "2024-04-19T05:11:34Z")

</div>

There is an ongoing effort to make these work by default

> <https://github.com/MakieOrg/Makie.jl/pull/3226>
>
> Continuation of #1347.
> 
> \#### Axis conversion
> \* Axis specifies types it can ha…ndle and creates objects that track global states for those types (e.g. categorical needs to track all categories of all plots in one axis)
> \* Axis compatible types =\> scene compatible types plus more types.
> \* Axis conversion can return axis parameters, which can be overridden step-by-step, similar to Plots.jl recipes.
> \* Scene conversions don't handle further axis-related tasks.
> \* For each plot command, we figure out the axis convert type, and then compare it to the existing axis conversion types in that axis. We then compare them by something like the Base.promotion trait system, and error if e.g. one tries to plot categorical values into a time axis.
> \* Each axis global (e.g. CategoricalConversion) will have an axis dimension associated and will be assigned to \`(dim)ticks\` of the axis, whcih then correctly creates axis labels etc.
> 
> \#### We can implement float32 rescaling as a axis conversion:
> \* Update data rescaling only when axis limits change.
> \* The "limits" referred to in rescaling aren't the axis limits but the 2D scene limits.
> \* Example: For user-facing limits from 1 to 100 and a log10 scale, scene limits would be 0 to 2. So, a real value of 1000 
> would be transformed to 3 and then rescaled to (3 - 0) / (2 - 0) = 1.5. 
> \* Example: Some type is converted by the axis to float128, which then gets converted + scaled for the scene to float32.
> \* The scene then converts float128 to float32.
> \* Transform functions need to occur before data rescaling
> \* We can optimize rescaling if inputs are already float32.
> 
> This PR right now ports all docs & examples and the actual implementation of unit conversions and bases it against https://github.com/MakieOrg/Makie.jl/pull/3113.
> We still need to implement the actual axis conversion more cleanly, which was the Achilles heel for #1347 and the reason it wasn't merged yet. Since most work was getting units, printing and conversions to work, I hope that now with a better plan the axis conversion won't take that long to implement anymore.

---

<div class="post-metadata">

**Author:** ![dk-zen](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dk-zen](https://discourse.julialang.org/u/dk-zen)\
**Post date:** [April 19, 2024, 6:03am UTC](https://discourse.julialang.org/t/makie-does-not-accept-vector-datatime-types/113218/3 "2024-04-19T06:03:14Z")

</div>

Hope for improvement!  
I get it using another way with Makie.

```julia
f = Figure(; size=(1000, 600))
ax = Axis(f[1, 1];
    xlabel=L"Time",
    ylabel=L"Electric Field (kV/m)",
    title="$(Date(time[1]))",
    xticks=(1:3599:84480, ["$(lpad(hour(time[i]),2,'0'))" * ":" * "$(lpad(minute(time[i]),2,'0'))" * ":" * "$(lpad(second(time[i]),2,'0'))" for i in 1:3599:84480]),
    xticklabelrotation=pi / 4)
lines!(ax, 1:84480, e)
f

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 19, 2024, 7:44am UTC](https://discourse.julialang.org/t/makie-does-not-accept-vector-datatime-types/113218/4 "2024-04-19T07:44:53Z")

</div>

Second time I’m making this joke on this forum, but I think this time I’m right:

![image](https://global.discourse-cdn.com/julialang/original/3X/a/d/ad3c1f365e2bf59698969f3bf1a3ad7c6315c2e4.jpeg)
