# How to define default plotting attributes for all my recipes using only \`RecipesBase.jl\`?

**URL:** <https://discourse.julialang.org/t/how-to-define-default-plotting-attributes-for-all-my-recipes-using-only-recipesbase-jl/93384>\
**Category:** General Usage\
**Tags:** plotting, recipe\
**Created:** [January 23, 2023, 8:04am UTC](https://discourse.julialang.org/t/how-to-define-default-plotting-attributes-for-all-my-recipes-using-only-recipesbase-jl/93384 "2023-01-23T08:04:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Post date:** [January 23, 2023, 8:04am UTC](https://discourse.julialang.org/t/how-to-define-default-plotting-attributes-for-all-my-recipes-using-only-recipesbase-jl/93384/1 "2023-01-23T08:04:29Z")

</div>

I have several `@recipe`s, which share the same `plotattribute`s, such as `framestyle`, `grid`, `legend_foreground_color`, etc. If `Plots.jl` is imported, I could just use `default`, right? But is it possible that I only use `RecipesBase.jl` without `Plots.jl` in my project?

MWE:

```julia
using RecipesBase: @recipe

@recipe function f(x, y)
    framestyle --> :box
    legend_foreground_color --> nothing
    grid --> nothing
    x, y
end
@recipe function f(x)
    framestyle --> :box
    legend_foreground_color --> nothing
    grid --> nothing
    x
end

```

---

<div class="post-metadata">

**Author:** ![jonniedie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonniedie/32/12842_2.png) [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Post date:** [April 25, 2023, 1:51pm UTC](https://discourse.julialang.org/t/how-to-define-default-plotting-attributes-for-all-my-recipes-using-only-recipesbase-jl/93384/2 "2023-04-25T13:51:04Z")

</div>

I’d like to know too. It seems like most packages just copy and paste attributes for each of their plot functions ([example](https://github.com/JuliaPhysics/Measurements.jl/blob/master/src/plot-recipes.jl), not to pick on Measurements.jl)

---

<div class="post-metadata">

**Author:** ![jonniedie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonniedie/32/12842_2.png) [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Post date:** [April 25, 2023, 1:55pm UTC](https://discourse.julialang.org/t/how-to-define-default-plotting-attributes-for-all-my-recipes-using-only-recipesbase-jl/93384/3 "2023-04-25T13:55:02Z")

</div>

You can’t really write a macro to inject your own defaults either, because macros expand from outside-in. I guess you could write one that injected a bunch of things that look like

```julia
RecipesBase.is_explicit(plotattributes, :labels) || (plotattributes[:labels] = nameof(ts))

```

but then you’d be relying on the implementation details of the `@recipe` macro that are likely to change in the future.
