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

Support for Unitful.Gain in axis recipes? #4801

Open
icweaver opened this issue Feb 17, 2025 · 0 comments
Open

Support for Unitful.Gain in axis recipes? #4801

icweaver opened this issue Feb 17, 2025 · 0 comments
Labels
enhancement Feature requests and enhancements

Comments

@icweaver
Copy link

Feature description

Would it be possible to add Unitful.Gain to the list of supported units in unitful-integrations.jl?

We're investigating transitioning some of our JuliaAstro plotting infra over to Makie.jl, but are currently hitting this issue when trying to work with units that are not Quantities, which comes up when dealing with magnitudes in UnitfulAstro or logarithmic units in base Unitful for example:

julia> using GLMakie, Unitful

julia> scatter((1:10)u"dB")
ERROR: ArgumentError:     Conversion failed for Scatter (With conversion trait PointBased()) with args: Tuple{Vector{Gain{Unitful.LogInfo{:Decibel, 10, 10}, :?, Int64}}} .
    Scatter requires to convert to argument types Tuple{AbstractVector{<:Union{Point2, Point3}}}, which convert_arguments didn't succeed in.
    To fix this overload convert_arguments(P, args...) for Scatter or PointBased() and return an object of type Tuple{AbstractVector{<:Union{Point2, Point3}}}.`

Stacktrace:
 [1] conversion_pipeline(P::Type{…}, used_attrs::Tuple{}, args::Tuple{…}, kw_obs::Observable{…}, args_obs::Tuple{…}, user_attributes::Dict{…}, deregister::Vector{…}, recursion::Int64)
   @ Makie ~/projects/Makie.jl/src/interfaces.jl:241
 [2] conversion_pipeline(P::Type{…}, used_attrs::Tuple{}, args::Tuple{…}, kw_obs::Observable{…}, args_obs::Tuple{…}, user_attributes::Dict{…}, deregister::Vector{…}, recursion::Int64)
   @ Makie ~/projects/Makie.jl/src/interfaces.jl:233
 [3] conversion_pipeline(P::Type{…}, used_attrs::Tuple{}, args::Tuple{…}, kw_obs::Observable{…}, args_obs::Tuple{…}, user_attributes::Dict{…}, deregister::Vector{…})
   @ Makie ~/projects/Makie.jl/src/interfaces.jl:213
 [4] (Scatter)(user_args::Tuple{Vector{Gain{Unitful.LogInfo{…}, :?, Int64}}}, user_attributes::Dict{Symbol, Any})
   @ Makie ~/projects/Makie.jl/src/interfaces.jl:273
 [5] _create_plot(F::Function, attributes::Dict{Symbol, Any}, args::Vector{Gain{Unitful.LogInfo{…}, :?, Int64}})
   @ Makie ~/projects/Makie.jl/src/figureplotting.jl:316
 [6] #scatter#54
   @ ~/.julia/packages/MakieCore/sHgwT/src/recipes.jl:510 [inlined]
 [7] scatter(args::Vector{Gain{Unitful.LogInfo{:Decibel, 10, 10}, :?, Int64}})
   @ MakieCore ~/.julia/packages/MakieCore/sHgwT/src/recipes.jl:508
 [8] top-level scope
   @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.

At any rate, #3226 has been a game changer for working with Unitful.jl, thank you for adding this support!

For plot types, please add an image of how it should look like

julia> using GLMakie, Unitful

julia> scatter((1:10)u"m")
# but replace "m" with "dB" or "mag"

Image

@icweaver icweaver added the enhancement Feature requests and enhancements label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests and enhancements
Projects
None yet
Development

No branches or pull requests

1 participant