# Makie recipe arguments

**URL:** <https://discourse.julialang.org/t/makie-recipe-arguments/77047>\
**Category:** Visualization\
**Tags:** question, plotting, makie\
**Created:** [February 25, 2022, 6:50am UTC](https://discourse.julialang.org/t/makie-recipe-arguments/77047 "2022-02-25T06:50:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![garrek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrek/32/27937_2.png) [@garrek](https://discourse.julialang.org/u/garrek)\
**Post date:** [February 25, 2022, 6:50am UTC](https://discourse.julialang.org/t/makie-recipe-arguments/77047/1 "2022-02-25T06:50:55Z")

</div>

I’m trying a write a recipe in Makie, but cannot use the extracted x and y values from the recipe. I’m following [the example](https://makie.juliaplots.org/stable/documentation/recipes/#full_recipes_with_the_recipe_macro) in the documentation, as well as the examples in [basic\_recipes.jl](https://github.com/JuliaPlots/Makie.jl/tree/master/src/basic_recipes) (particularly pie.jl). The error message seems to indicate that `MyPlot` does take any arguments, but I thought the `@recipe` macro expands into a type definition that includes the plot and argument types.

I want to extract the arguments so that I can operate on them by changing a length and angle `(r, θ)` to `(x, y)` coordinates to make a polar plot. I provide just a basic example below closely following the docs.

Recipe:

```julia
@recipe(MyPlot, x, y) do scene
    Theme(
        plot_color = :red
    )
end

```

Try 1:

```julia
function plot!(myplot::MyPlot)  

    x = myplot[1]
    y = myplot[2]

    scatter!(myplot, x, y, color = myplot.plot_color)
    myplot
end

```

Try 2:

```julia
function plot!(myplot::MyPlot)  

    x = myplot[:x]
    y = myplot[:y]

    scatter!(myplot, x, y, color = myplot.plot_color)
    myplot
end

```

Plot:

```julia
f = Figure
ax = Axis(f[1, 1])

myplot(ax, rand(10), rand(10))

```

Error message:

```julia
ERROR: PlotMethodError: no myplot method for arguments (::Axis, ::Vector{Float64}, ::Vector{Float64}). To support these arguments, define
  plot!(::Combined{myplot, S} where S<:Tuple{Axis, Vector{Float64}, Vector{Float64}})

```

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [February 25, 2022, 1:49pm UTC](https://discourse.julialang.org/t/makie-recipe-arguments/77047/2 "2022-02-25T13:49:09Z")

</div>

its `myplot(...)` or `myplot!(ax, ...)`  
Also make sure you actually overload `Makie.plot!(myplot::MyPlot)`

---

<div class="post-metadata">

**Author:** ![garrek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrek/32/27937_2.png) [@garrek](https://discourse.julialang.org/u/garrek)\
**Post date:** [February 25, 2022, 10:30pm UTC](https://discourse.julialang.org/t/makie-recipe-arguments/77047/3 "2022-02-25T22:30:07Z")

</div>

Thank you, that worked. For others who come across this question, this is the solution:

```julia
using CairoMakie
using Makie

@recipe(MyPlot, x, y) do scene
    Attributes(
        plot_color = :red
    )
end

function Makie.plot!(myplot::MyPlot)  

    # All three ways work

    # x = myplot[1]
    # y = myplot[2]

    # x = myplot[:x]
    # y = myplot[:y]

    x = myplot.x
    y = myplot.y

    scatter!(myplot, x, y, color = myplot[:plot_color])
    myplot
end

f = Figure()
ax = Axis(f[1, 1])

myplot!(ax, rand(10), rand(10))

f

```

 ![plot_1](https://global.discourse-cdn.com/julialang/original/3X/6/3/63db4ee041ed7e4e422279bc96727688bc3cc875.png)
