# Where is the right place to put default settings for Plots.jl

**URL:** <https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149>\
**Category:** General Usage\
**Tags:** question, plotting, plots\
**Created:** [February 10, 2022, 8:09am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149 "2022-02-10T08:09:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 10, 2022, 8:09am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/1 "2022-02-10T08:09:52Z")

</div>

I would like to set the default plotting style, e.g., default(grid=:off, box=:on)， when using Plots.jl to avoid doing it every time when I need to use it.  
putting it in `startup.jl` doesn’t work as an error occurs. So where is the right place?

```julia
ERROR: LoadError: UndefVarError: default not defined
Stacktrace:
 [1] top-level scope
   @ C:\Users\xxx\.julia\config\startup.jl:1
in expression starting at C:\Users\xxx\.julia\config\startup.jl:1

```

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 10, 2022, 8:17am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/2 "2022-02-10T08:17:24Z")

</div>

I would say at the top of each script. If you want to call `default`, you need to have `Plots` loaded. And putting `using Plots` in your `startup` is probably not something you want.

You can define a `mydefaults` constant in `startup`, and do `default(mydefaults...)` if you want.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 10, 2022, 8:21am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/3 "2022-02-10T08:21:22Z")

</div>

I have in my startup.jl:

```julia
const PLOTS_DEFAULTS = Dict(:theme => :wong, :fontfamily => "Computer Modern",
    :label => nothing, :dpi => 600
)

```

---

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 10, 2022, 8:24am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/4 "2022-02-10T08:24:21Z")

</div>

This really solved the problem! thanks!

---

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 10, 2022, 8:29am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/5 "2022-02-10T08:29:25Z")

</div>

Then one last question, :legend\_background\_color=\> “ARGB(1.0,1.0,1.0,0.5)” leads to an error, is there an way to get this right?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 10, 2022, 8:40am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/6 "2022-02-10T08:40:07Z")

</div>

> [@Fred\_He](#):
>
> ARGB(1.0,1.0,1.0,0.5)

That seems to require Plots.jl to be loaded at startup.  
I would try something more generic like:

```julia
:legend_background_color => :transparent

```

You need to test the exact syntax required and also remove the frame around the legend, I guess. But do not know now how to do partial transparency easily in startup.jl. To think about.

---

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 10, 2022, 8:46am UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/7 "2022-02-10T08:46:33Z")

</div>

That’s a way 😀 , although I want half transparency. Thank you!

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [February 10, 2022, 12:37pm UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/8 "2022-02-10T12:37:37Z")

</div>

Try:

const PLOTS\_DEFAULTS = Dict(:legend\_background\_color =\> “0x88ffffff”)

I am not able to test it right now, but I have used it as a direct parameter to plot.

---

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [February 10, 2022, 1:31pm UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/9 "2022-02-10T13:31:38Z")

</div>

test passed!

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 10, 2022, 1:32pm UTC](https://discourse.julialang.org/t/where-is-the-right-place-to-put-default-settings-for-plots-jl/76149/10 "2022-02-10T13:32:23Z")

</div>

It works!

For future reference, we could find the hexadecimal colour code using:

```julia
using Colors
hex(ARGB(1.0,1.0,1.0,0.5))
"80FFFFFF"

```
