# Makie recipe usage

**URL:** <https://discourse.julialang.org/t/makie-recipe-usage/54292>\
**Category:** Visualization\
**Tags:** question, plotting, makie, recipe\
**Created:** [January 30, 2021, 7:14pm UTC](https://discourse.julialang.org/t/makie-recipe-usage/54292 "2021-01-30T19:14:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Post date:** [January 30, 2021, 7:14pm UTC](https://discourse.julialang.org/t/makie-recipe-usage/54292/1 "2021-01-30T19:14:56Z")

</div>

I read about a post [makie-recipe-specialisation-for-specific-types](https://discourse.julialang.org/t/makie-recipe-specialisation-for-specific-types/39157) for plotting customized types from Makie. The official document also has a [Plot-Recipes](https://makie.juliaplots.org/stable/recipes.html#Plot-Recipes) section, but I still do not understand how to use it. Additionally, there is a [MakieRecipes](https://github.com/JuliaPlots/MakieRecipes.jl) repo which makes it more confusing to me.

Let me start with my first attempt, following the [Type-recipes](https://makie.juliaplots.org/stable/recipes.html#Type-recipes) example in the document:

```julia
using Makie

struct MyType
   data::Vector
end

convert_arguments(P::Type{<:AbstractPlot}, x::MyType) = (rand(10),)

fig = Figure(resolution = (1200, 700), backgroundcolor = RGBf0(0.98, 0.98, 0.98))
ax1 = fig[1, 1] = Axis(fig, title = "test")

mydata = MyType(ones(10))
plot!(mydata)
fig

```

which displayed error

```julia
ERROR: LoadError: Plotting for the arguments (::MyType) not defined. If you want to support those arguments, overload plot!(plot::Plot(MyType,))

```

Hmm weird. Why do I need to overload the plotting functions if it is a recipe? Indeed adding

```julia
function AbstractPlotting.plot!(mydata::MyType)
   plot!(mydata.data)
end

```

works in this case, but that is different from what I expected.

I then realized from [this reply to a similar post](https://discourse.julialang.org/t/makie-recipe-specialisation-for-specific-types/39157/2) that I need to import `AbstractPlotting`, so my second attempt is

```julia

using Makie

struct MyType
   data::Vector
end

AbstractPlotting.convert_arguments(P::Type{<:AbstractPlot}, x::MyType) = (rand(10),)

fig = Figure(resolution = (1200, 700), backgroundcolor = RGBf0(0.98, 0.98, 0.98))
ax1 = fig[1, 1] = Axis(fig, title = "test")

mydata = MyType(ones(10))
plot!(mydata)
fig

```

It seemed like defining a `convert_arguments` which returns a tuple was all I needed. However, this also again complains:

```julia
ERROR: LoadError: MethodError: no method matching to_ndim(::Type{Vec{3,Float32}}, ::Float64, ::Int64)
Closest candidates are:
  to_ndim(::Type{var"#s81"} where var"#s81"<:Union{Tuple{Vararg{ET,N}}, StaticArrays.StaticArray{Tuple{N},ET,1}}, ::Union{Tuple{Vararg{T,N2}}, StaticArrays.StaticArray{Tuple{N2},T,1}} where T, ::Any) where {N, ET, N2} at /home/hongyang/.julia/packages/AbstractPlotting/ll2vf/src/utilities/utilities.jl:188

```

What am I missing here? Besides this, is the development for [MakieRecipes](https://github.com/JuliaPlots/MakieRecipes.jl) a completely parallel effort?

@asinghvi17

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 31, 2021, 12:09am UTC](https://discourse.julialang.org/t/makie-recipe-usage/54292/2 "2021-01-31T00:09:59Z")

</div>

you should be reading this  
[http://makie.juliaplots.org/stable/recipes.html](http://makie.juliaplots.org/stable/recipes.html)

---

<div class="post-metadata">

**Author:** ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Post date:** [January 31, 2021, 9:06am UTC](https://discourse.julialang.org/t/makie-recipe-usage/54292/3 "2021-01-31T09:06:17Z")

</div>

Isn’t it the same link I shared in the main post? That’s where I got confused.
