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

scatter!(ax, Any[(0,0), (1,1)]) doesn't work #1451

Closed
goretkin opened this issue Nov 16, 2021 · 1 comment
Closed

scatter!(ax, Any[(0,0), (1,1)]) doesn't work #1451

goretkin opened this issue Nov 16, 2021 · 1 comment

Comments

@goretkin
Copy link
Contributor

using GLMakie

fig = Figure()
ax = Axis(fig[1, 1], title = "Demo")
scatter!(ax, Any[(0,0), (1,1)])
fig

gives

ERROR: LoadError: `Makie.convert_arguments` for the plot type Scatter{Tuple{Vector{Any}}} and its conversion trait PointBased() was unsuccessful.

The signature that could not be converted was:
::Vector{Any}
[...truncated. full output below...]

Here is one idiom for tightening the type of a Vector:

julia> identity.(Vector{Any}([(0, 0), (1, 1)]))
2-element Vector{Tuple{Int64, Int64}}:
 (0, 0)
 (1, 1)

I think Makie should handle this for the user.

Full error:

ERROR: LoadError: `Makie.convert_arguments` for the plot type Scatter{Tuple{Vector{Any}}} and its conversion trait PointBased() was unsuccessful.

The signature that could not be converted was:
::Vector{Any}

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://makie.juliaplots.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.

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:33
  [2] convert_arguments(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:17
  [3] convert_arguments(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:8
  [4] plot!(scene::Scene, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:321
  [5] plot!(scene::Scene, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:308
  [6] plot!(la::Axis, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:658
  [7] plot!(la::Axis, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:653
  [8] plot!(P::Type{Scatter{ArgType} where ArgType}, ax::Axis, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:670
  [9] plot!(P::Type{Scatter{ArgType} where ArgType}, ax::Axis, args::Vector{Any})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:669
 [10] scatter!(::Axis, ::Vararg{Any, N} where N; attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [11] scatter!(::Axis, ::Vararg{Any, N} where N)
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [12] top-level scope
    @ Untitled-2:5
in expression starting at Untitled-2:5

caused by: MethodError: no method matching convert_arguments(::Type{Scatter{Tuple{Vector{Any}}}}, ::Vector{Any})
Closest candidates are:
  convert_arguments(::Union{Type{Any}, Type{var"#s268"} where var"#s268"<:AbstractPlot}, ::Union{AbstractVector{T} where T, IntervalSets.Interval}, ::Distributions.Distribution) at /Users/goretkin/.julia/packages/Makie/gQOQF/src/stats/distributions.jl:21
  convert_arguments(::Union{Type{Any}, Type{var"#s268"} where var"#s268"<:AbstractPlot}, ::AbstractVector{T} where T, ::Function) at /Users/goretkin/.julia/packages/Makie/gQOQF/src/conversions.jl:546
  convert_arguments(::Union{Type{Any}, Type{var"#s268"} where var"#s268"<:AbstractPlot}, ::Any...; kw...) at /Users/goretkin/.julia/packages/Makie/gQOQF/src/conversions.jl:7
  ...
Stacktrace:
  [1] convert_arguments_individually(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:47
  [2] convert_arguments(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:14
  [3] convert_arguments(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:8
  [4] plot!(scene::Scene, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:321
  [5] plot!(scene::Scene, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:308
  [6] plot!(la::Axis, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:658
  [7] plot!(la::Axis, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:653
  [8] plot!(P::Type{Scatter{ArgType} where ArgType}, ax::Axis, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:670
  [9] plot!(P::Type{Scatter{ArgType} where ArgType}, ax::Axis, args::Vector{Any})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:669
 [10] scatter!(::Axis, ::Vararg{Any, N} where N; attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [11] scatter!(::Axis, ::Vararg{Any, N} where N)
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [12] top-level scope
    @ Untitled-2:5

caused by: MethodError: no method matching convert_arguments(::PointBased, ::Vector{Any})
Closest candidates are:
  convert_arguments(::PointBased, ::AbstractVector{T} where T, ::AbstractVector{T} where T, ::AbstractMatrix{T} where T) at /Users/goretkin/.julia/packages/Makie/gQOQF/src/conversions.jl:104
  convert_arguments(::SurfaceLike, ::AbstractVector{T1}, ::AbstractVector{T2}, ::Function) where {T1, T2} at /Users/goretkin/.julia/packages/Makie/gQOQF/src/conversions.jl:348
  convert_arguments(::Type{var"#s740"} where var"#s740"<:(Combined{Makie.qqplot, ArgType} where ArgType), ::Any...; kwargs...) at /Users/goretkin/.julia/packages/Makie/gQOQF/src/stats/distributions.jl:40
  ...
Stacktrace:
  [1] convert_arguments(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:10
  [2] convert_arguments(T::Type{Scatter{Tuple{Vector{Any}}}}, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/conversions.jl:8
  [3] plot!(scene::Scene, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:321
  [4] plot!(scene::Scene, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any})
    @ Makie ~/.julia/packages/Makie/gQOQF/src/interfaces.jl:308
  [5] plot!(la::Axis, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:658
  [6] plot!(la::Axis, P::Type{Scatter{ArgType} where ArgType}, attributes::Attributes, args::Vector{Any})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:653
  [7] plot!(P::Type{Scatter{ArgType} where ArgType}, ax::Axis, args::Vector{Any}; kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:670
  [8] plot!(P::Type{Scatter{ArgType} where ArgType}, ax::Axis, args::Vector{Any})
    @ Makie.MakieLayout ~/.julia/packages/Makie/gQOQF/src/makielayout/layoutables/axis.jl:669
  [9] scatter!(::Axis, ::Vararg{Any, N} where N; attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [10] scatter!(::Axis, ::Vararg{Any, N} where N)
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:35
 [11] top-level scope
    @ Untitled-2:5
@ffreyer
Copy link
Collaborator

ffreyer commented May 24, 2024

Fixed in 0.21

@ffreyer ffreyer closed this as completed May 24, 2024
This issue was closed.
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