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

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).

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?

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

2 Likes

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.

1 Like