Skip to content

Support for Unitful.Gain in axis recipes? #4801

Description

@icweaver

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MakieBackend independent issues (Makie core)enhancementFeature requests and enhancementsunitsaka dim converts

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions