# How do I create a Makie recipe with keyword-argument?

**URL:** <https://discourse.julialang.org/t/how-do-i-create-a-makie-recipe-with-keyword-argument/110641>\
**Category:** General Usage\
**Tags:** makie\
**Created:** [February 23, 2024, 1:10pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-makie-recipe-with-keyword-argument/110641 "2024-02-23T13:10:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larbino1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/larbino1/32/37831_2.png) [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Post date:** [February 23, 2024, 1:10pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-makie-recipe-with-keyword-argument/110641/1 "2024-02-23T13:10:02Z")

</div>

Let me explain my case:

I want to create a plotting function that plots a 3D transformation by drawing x-y-z axes relative to the origin.

I’m not decided whether or not to use `scatter` or give it a custom name like `plottransform.` I’m familiar with making Makie recipes from [the tutorial](https://docs.makie.org/stable/explanations/recipes/), but I can’t tell how to create keyword/default arguments.

For example I want to be able to do any of the following:

```julia
plottransform(tf)
plottransform(tf, size=1.0)
plottransform(tf, axiscolors=(:red, :green, :blue))
plottransform!(ax, tf, size=1.0)

```

etc.

Can you point me to a resource that explain how this is achieved ideomatically with Makie?

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [February 23, 2024, 1:50pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-makie-recipe-with-keyword-argument/110641/2 "2024-02-23T13:50:54Z")

</div>

You would add your keyword arguments somewhere [here](https://docs.makie.org/stable/explanations/recipes/#:~:text=do%20scene%0A%20%20%20%20Theme(-,plot_color%20%3D%20%3Ared,-)%0Aend) as in the docs. For this I would recommend creating a full recipe - it gives you a lot more control!

---

<div class="post-metadata">

**Author:** ![Larbino1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/larbino1/32/37831_2.png) [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Post date:** [February 23, 2024, 3:30pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-makie-recipe-with-keyword-argument/110641/3 "2024-02-23T15:30:33Z")

</div>

That’s the same page I linked. I’ll be more clear; say I have the example recipe from that page

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

```

Where in this bit of code do I add a kwarg, with a default value? Do I just do this:?

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

```

There are no example of this that I can find.

---

<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 23, 2024, 4:36pm UTC](https://discourse.julialang.org/t/how-do-i-create-a-makie-recipe-with-keyword-argument/110641/4 "2024-02-23T16:36:57Z")

</div>

```julia
@recipe(MyPlot, x, y, z) do scene
    Theme(
        plot_color = :red # this is the default value for keyword arguments
    )
end

function Makie.plot!(p::MyPlot) 
    p.plot_color[] == :red # is red, if not passed something else by user. `[]` because its an observable
end

```
