# \`Makie.convert\_arguments\` example

**URL:** <https://discourse.julialang.org/t/makie-convert-arguments-example/70823>\
**Category:** General Usage\
**Tags:** plotting, makie\
**Created:** [November 2, 2021, 6:40pm UTC](https://discourse.julialang.org/t/makie-convert-arguments-example/70823 "2021-11-02T18:40:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [November 2, 2021, 6:40pm UTC](https://discourse.julialang.org/t/makie-convert-arguments-example/70823/1 "2021-11-02T18:40:16Z")

</div>

I found this [https://makie.juliaplots.org/stable/documentation/recipes/](https://makie.juliaplots.org/stable/documentation/recipes/) but I’m not able to able to follow it to be honest.

For example, let’s have a struct

```julia
struct A
    val::Float32
end

```

which I want to plot by

```julia
using CairoMakie
y = [A(convert(Float32, i^2) for i in 1:20);]
lines(y)

```

I tried

```julia
get(a::A) = a.x
Makie.convert_arguments(P::PointBased, a::Vector{A}) = (Float32.(get.(a)),)

```

but I get an error

```julia
MethodError: no method matching to_ndim(::Type{GeometryBasics.Vec{3, Float32}}, ::Float32, ::Int64)

Closest candidates are:

to_ndim(::Type{var"#s12"} where var"#s12"<:Union{Tuple{Vararg{ET, N}}, StaticArrays.StaticVector{N, ET}}, !Matched::Union{Tuple{Vararg{T, N2}}, StaticArrays.StaticVector{N2, T}} where T, ::Any) where {N, ET, N2} at /home/christian/.julia/packages/Makie/gQOQF/src/utilities/utilities.jl:203

    1. xyz_boundingbox(::Function, ::Vector{Float32})@data_limits.jl:67
    2. atomic_limits(::MakieCore.Lines{Tuple{Vector{Float32}}})@data_limits.jl:17
    3. data_limits@data_limits.jl:9[inlined]
    4. push!(::Makie.Scene, ::MakieCore.Lines{Tuple{Vector{Float32}}})@scenes.jl:364
    5. plot!(::Makie.Scene, ::Type{MakieCore.Lines{Tuple{Vector{Main.workspace#8.A}}}}, ::MakieCore.Attributes, ::Tuple{Observables.Observable{Vector{Main.workspace#8.A}}}, ::Observables.Observable{Tuple{Vector{Float32}}})@interfaces.jl:430
    6. var"#plot!#159"(::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:show_axis,), Tuple{Bool}}}, ::typeof(MakieCore.plot!), ::Makie.Scene, ::Type{MakieCore.Lines{ArgType} where ArgType}, ::MakieCore.Attributes, ::Vector{Main.workspace#8.A})@interfaces.jl:339
    7. var"#plot#948"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(MakieCore.plot), ::Type{MakieCore.Lines{ArgType} where ArgType}, ::Vector{Main.workspace#8.A})@figureplotting.jl:28
    8. plot@figureplotting.jl:18[inlined]
    9. #lines#29@recipes.jl:31[inlined]
   10. lines(::Vector{Main.workspace#8.A})@recipes.jl:31
   11. top-level scope@Local: 1[inlined]

```

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [November 2, 2021, 7:31pm UTC](https://discourse.julialang.org/t/makie-convert-arguments-example/70823/2 "2021-11-02T19:31:37Z")

</div>

I think `PointBased` needs to get to `Tuple{Vector{Point{D, Float32}}}`. So either you convert to that directly or you continue the pipeline with

```julia
Makie.convert_arguments(P::PointBased, a::Vector{A}) = convert_arguments(P, get.(a))

```

---

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [November 2, 2021, 8:47pm UTC](https://discourse.julialang.org/t/makie-convert-arguments-example/70823/3 "2021-11-02T20:47:43Z")

</div>

thanks!

---

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [November 2, 2021, 9:06pm UTC](https://discourse.julialang.org/t/makie-convert-arguments-example/70823/4 "2021-11-02T21:06:22Z")

</div>

And how does it work with `Makie.convert_single_argument`?

```julia
Makie.convert_single_argument(a::Vector{A}) = Float32.(get.(a))
lines(y)

```

yields

```julia
MethodError: no method matching to_ndim(::Type{GeometryBasics.Vec{3, Float32}}, ::Float32, ::Int64)

Closest candidates are:

to_ndim(::Type{var"#s12"} where var"#s12"<:Union{Tuple{Vararg{ET, N}}, StaticArrays.StaticVector{N, ET}}, !Matched::Union{Tuple{Vararg{T, N2}}, StaticArrays.StaticVector{N2, T}} where T, ::Any) where {N, ET, N2} at /home/christian/.julia/packages/Makie/gQOQF/src/utilities/utilities.jl:203

    1. xyz_boundingbox(::Function, ::Vector{Float32})@data_limits.jl:67
    2. atomic_limits(::MakieCore.Lines{Tuple{Vector{Float32}}})@data_limits.jl:17
    3. data_limits@data_limits.jl:9[inlined]
    4. push!(::Makie.Scene, ::MakieCore.Lines{Tuple{Vector{Float32}}})@scenes.jl:364
    5. plot!(::Makie.Scene, ::Type{MakieCore.Lines{Tuple{Vector{Main.workspace#8.A}}}}, ::MakieCore.Attributes, ::Tuple{Observables.Observable{Vector{Main.workspace#8.A}}}, ::Observables.Observable{Tuple{Vector{Float32}}})@interfaces.jl:430
    6. var"#plot!#159"(::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:show_axis,), Tuple{Bool}}}, ::typeof(MakieCore.plot!), ::Makie.Scene, ::Type{MakieCore.Lines{ArgType} where ArgType}, ::MakieCore.Attributes, ::Vector{Main.workspace#8.A})@interfaces.jl:339
    7. var"#plot#948"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(MakieCore.plot), ::Type{MakieCore.Lines{ArgType} where ArgType}, ::Vector{Main.workspace#8.A})@figureplotting.jl:28
    8. plot@figureplotting.jl:18[inlined]
    9. #lines#29@recipes.jl:31[inlined]
   10. lines@recipes.jl:31[inlined]
   11. top-level scope@Local: 1[inlined]

```
