# Makie Basic Overloads for Composite Type

**URL:** <https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757>\
**Category:** General Usage\
**Tags:** makie, geometrybasics\
**Created:** [September 11, 2023, 7:05pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757 "2023-09-11T19:05:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 11, 2023, 7:05pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757/1 "2023-09-11T19:05:12Z")

</div>

I have a simple composite type I use to keep track of a 3D vector that looks like this.

```julia
abstract type AbstractVec{T<:Number} end

" xyzVecT is the object definition to contain the cartesian information "
struct xyzVecT{T} <:AbstractVec{T}
    x::T
    y::T
    z::T
end

```

It was one of the first custom types I made learning Julia, so I’ve gradually been trying to make it work with the more advanced packages like diffeqs and makie, etc. I thought I had it working with Makie, until I tried to Makie it also work with Symbolics and I think I’ve broken something. At the same time I started breaking things out into Package extensions, but that shouldn’t matter for this case.

So my first thought is, there is probably instruction out there that kind of tells how to do this generically, but I haven’t found it and the piece of Makie that I’m getting stuck on is convert\_single\_argument as there are very few words and no examples written about it in the Recipes manual for Makie.

I had tried to “overload” the Point3 function in geometry basics because I had done some things incorrectly and this is called by my convert\_single\_argument.

```julia
GeometryBasics.Point3(v::xyzVecT{T}) where {T<:AbstractFloat} = GeometryBasics.Point3{T}(v.x, v.y, v.z)
MakieCore.convert_single_argument(v::xyzVecT{T}) where T<:AbstractFloat = GeometryBasics.Point3{T}(v)

```

One thing that isn’t clear is, do I really need a version of convert\_single\_argument that takes a vector and not a single point or do I define the single point and it automatically can handle a vector version of it. I’m thinking I need to make it recognize a Vector case.

But I think in general I need to figure out why this doesn’t work.

```julia
x1=xyzVecT(1.0,2.0,3.0)
    @show decompose(Point3f,x1)

```

MethodError: no method matching coordinates(::xyzVector.xyzVecT{Float64})

Any good guides on how to build up custom composite types to work correctly with all of these tools. I’m not quite getting it from the “recipes” tutorial in Makie.

Thanks again for the noob questions.

Allan

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 11, 2023, 7:10pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757/2 "2023-09-11T19:10:14Z")

</div>

If you actually want a `Point3D` type, you probably want to subtype a `FieldVector` from `StaticArrays`:

```julia
struct Point3D{T} <: FieldVector{3,T}
    x::T
    y::T
    z::T
end

```

and you’ll get all (most?) of what you want. But I’m not answering the other specific details, for sure.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 11, 2023, 7:14pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757/3 "2023-09-11T19:14:22Z")

</div>

I started all this before static arrays was really as big a deal as it is now and before fieldvectors were available, so I’m not ready to abandon what I’m doing yet. What I have is kind of backwards compatible with some pre-existing MATLAB and C++ codes and works with other libraries I have that were based on some of these conversions. I also wanted it to be as efficient as possible for this type of thing. Maybe one day I’ll swap them out if the Static Arrays is any faster.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 11, 2023, 8:15pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757/4 "2023-09-11T20:15:44Z")

</div>

What am I missing?

```julia

import MakieCore
import MakieCore: convert_single_argument

MakieCore.convert_single_argument(v::xyzVecT{T}) where T<:AbstractFloat = GeometryBasics.Point3{T}(v)

```

> WARNING: could not import MakieCore.convert\_single\_argument into xyzVectorMakieExt  
> ERROR: LoadError: UndefVarError: `convert_single_argument` not defined

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 11, 2023, 9:24pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757/5 "2023-09-11T21:24:05Z")

</div>

> [@Allan\_Baker](#):
>
> `decompose`

I don’t know why I got off on decompose here. I didn’t really know what it was for in the examples. I don’t think I can decompose a vector into coordinates or faces since it is only a single point. Perhaps it needs to be an array of these xyzVecT’s to decompose.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [September 11, 2023, 9:25pm UTC](https://discourse.julialang.org/t/makie-basic-overloads-for-composite-type/103757/6 "2023-09-11T21:25:26Z")

</div>

> [@Allan\_Baker](#):
>
> import

So I went to go look to see why MakieCore didn’t have convert\_single\_argument like the documentation implied, and it says it is depreciated. So I switched this dependency to Makie and it appears to work fine. Not sure what the documentation is supposed to say.
