# How to ensure Makie's theme activation occurs when called in a module?

**URL:** <https://discourse.julialang.org/t/how-to-ensure-makies-theme-activation-occurs-when-called-in-a-module/116114>\
**Category:** Visualization\
**Tags:** package, makie\
**Created:** [June 23, 2024, 2:36pm UTC](https://discourse.julialang.org/t/how-to-ensure-makies-theme-activation-occurs-when-called-in-a-module/116114 "2024-06-23T14:36:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [June 23, 2024, 2:36pm UTC](https://discourse.julialang.org/t/how-to-ensure-makies-theme-activation-occurs-when-called-in-a-module/116114/1 "2024-06-23T14:36:30Z")

</div>

I had some script with lots of convenience plotting functions for Makie, as well as a bunch of themes I like to use in my work. For reproducibility I decided to make it a Julia package so that it can be added and its git hash is referenced.

Inside my module there is the line:

[`set_theme!(DEFAULT_THEME)`](https://github.com/Datseris/MakieThemeing.jl/blob/main/src/MakieThemeing.jl#L161).

Unfortunately, when i do `using MakieThemeing`,  
this line is ignored. I don’t know if it is run or not, but Makie doesn’t register it. It keeps the default theme. I need to do in addition again  
`set_theme!(DEFAULT_THEME)` after `using MakieThemeing`, for the theme setting to work.

Why do I have to do this twice and how can I make it so that it happens automatically on `using MakieThemeing`?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 23, 2024, 2:39pm UTC](https://discourse.julialang.org/t/how-to-ensure-makies-theme-activation-occurs-when-called-in-a-module/116114/2 "2024-06-23T14:39:52Z")

</div>

put that in ` __init__ ()`, it is not called at `using` time but only at precompilation time the way you wrote it. Cf. [Top level code in JuliaLang doesn't do what you think it does](https://www.oxinabox.net/2023/06/16/top-level-code-in-julia.html)

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [June 23, 2024, 6:27pm UTC](https://discourse.julialang.org/t/how-to-ensure-makies-theme-activation-occurs-when-called-in-a-module/116114/3 "2024-06-23T18:27:05Z")

</div>

As this is directly related, is there any way to also export variables defined inside the ` __init__ ()` function? I need this to export my `COLORS` variable because Makie doesn’t support `to_color(::Cycled)` there isn’t any other way for me to actually obtain the colors of the color cycle.

EDIT: To answer my question, it is as simple as adding a `global` decleration before the variable.
