# How to write Plots/Makie recipes for a module without having it precompile

**URL:** <https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717>\
**Category:** General Usage\
**Tags:** plots, recipe\
**Created:** [November 3, 2022, 2:27pm UTC](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717 "2022-11-03T14:27:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danilo-bc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danilo-bc/32/19590_2.png) [@danilo-bc](https://discourse.julialang.org/u/danilo-bc)\
**Post date:** [November 3, 2022, 2:27pm UTC](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717/1 "2022-11-03T14:27:33Z")

</div>

I’m trying to create a Julia modules for simple mathematical functions, but I want to separate code which calculates from code which show stuff on the screen (plot recipes).

I want each mathematical domain to be in their own module (QuadraticFunctions, CubicFunctions) because I want to learn about precompilation. This way, if I change one module, I don’t have to precompile all my work environment.

The problem is that in order to create a recipe, like `plot(some_data, color=:green)` (code may be wrong, but focusing on having a specific color to a specific Module), I need to either mention my block uses Plots/Makie or imports Plots/Makie.

This means that I suddenly added this huge dependency on my calculation package just because I want to make a few plotting recipes available.

Plots/Makie will be imported and used on a `main.jl` like

```julia
using QuadraticFunctions
using CubicFunctions
using Plots
gr()

##### plots and calls to functions exported by both modules #####

```

Is there any better solution I’m not thinking about? Or do I just have to separate one module into two modules so I have `QuadraticFunctions` and `QuadraticFunctionsRecipes`, which depends on the calculations module? This way, changes to the internals of the modules which calculate will only trigger recompilation of their own things, not including any graphical package.

---

<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:** [November 4, 2022, 11:35am UTC](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717/2 "2022-11-04T11:35:53Z")

</div>

Only `using RecipesBase` should be required (to later use your package with Plots.jl).

See [this post](https://discourse.julialang.org/t/understanding-recipes-in-plots-jl/1912) for more info.

---

<div class="post-metadata">

**Author:** ![danilo-bc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danilo-bc/32/19590_2.png) [@danilo-bc](https://discourse.julialang.org/u/danilo-bc)\
**Post date:** [November 7, 2022, 11:24am UTC](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717/3 "2022-11-07T11:24:49Z")

</div>

Thank you, I’ll check it out and reply once I get to test it in the following days!

---

<div class="post-metadata">

**Author:** ![danilo-bc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danilo-bc/32/19590_2.png) [@danilo-bc](https://discourse.julialang.org/u/danilo-bc)\
**Post date:** [November 10, 2022, 5:33pm UTC](https://discourse.julialang.org/t/how-to-write-plots-makie-recipes-for-a-module-without-having-it-precompile/89717/4 "2022-11-10T17:33:54Z")

</div>

After experimenting and researching my problem, I found that your solution is great for Plots, but Makie still requires the use of [Requires.jl](https://github.com/JuliaPackaging/Requires.jl) until MakieCore is sorted.

A working example of this is:

```julia
@require Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" begin
        include("my-extra-plots.jl")
        export my_extra_plot_function
    end

```

Where `my-extra-plots.jl` contains explicit references to Makie, like `Makie.plot` or `Makie.stem!`.
