Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates and Unitful #15

Open
jariji opened this issue Jul 18, 2024 · 3 comments
Open

Dates and Unitful #15

jariji opened this issue Jul 18, 2024 · 3 comments

Comments

@jariji
Copy link

jariji commented Jul 18, 2024

I like to plot data from Dates.jl and Unitful.jl.

julia> tab = StructArray(a=(1:10)u"m", b=(10:10:100)u"s")
10-element StructArray(::StepRange{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}, ::StepRange{Quantity{Int64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, Quantity{Int64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}) with eltype @NamedTuple{a::Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, b::Quantity{Int64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}}:
 (a = 1 m, b = 10 s)
 (a = 2 m, b = 20 s)
 (a = 3 m, b = 30 s)
 (a = 4 m, b = 40 s)
 (a = 5 m, b = 50 s)
 (a = 6 m, b = 60 s)
 (a = 7 m, b = 70 s)
 (a = 8 m, b = 80 s)
 (a = 9 m, b = 90 s)
 (a = 10 m, b = 100 s)

julia> Plot(data=tab, encodings=(;x=(;field=:a), y=(;field=:b)), graphic=Circle(r=5)) |> draw
ERROR: MethodError: no method matching wilk_ext(::Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, ::Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}, ::Int64)


Closest candidates are:
  wilk_ext(::Real, ::Real, ::Real, ::Any, ::Vector{<:Real}, ::Vector{<:Real})
   @ Vizagrams ~/.julia/packages/Vizagrams/gWrWE/src/auxiliar/generate_ticks_ext_wilkinson.jl:92
  wilk_ext(::Real, ::Real, ::Real, ::Any, ::Vector{<:Real})
   @ Vizagrams ~/.julia/packages/Vizagrams/gWrWE/src/auxiliar/generate_ticks_ext_wilkinson.jl:92
  wilk_ext(::Real, ::Real, ::Real, ::Any)
   @ Vizagrams ~/.julia/packages/Vizagrams/gWrWE/src/auxiliar/generate_ticks_ext_wilkinson.jl:92
@davibarreira
Copy link
Owner

This seems like it would be easy to port. I'll take a look.

@davibarreira
Copy link
Owner

@jariji , sorry for taking so long. I had to refactor some major parts of the code.

Anyways, now I can actually address the issue here. I got your example to work. The code pretty much strips the units before computing scales and other stuff. Do you have other examples I can perhaps try before modifying the code?
I don't commonly use Unitful.

@jariji
Copy link
Author

jariji commented Aug 21, 2024

Please don't rush, I'm mostly just curious about the library at this point.

If you're interested, however, some other examples would be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants