Closed milankl closed 2 months ago
Yes, yes, yes!
I can help out!
I can help out!
Yeah, I don't think I've set up the extension correctly. I thought
heatmap
function therein for ::AbstractGrid
export heatmap
in SpeedyWeather?heatmap
method for ::AbstractGrid
when using CairoMakie
(which also imports Makie, so I assumed that would trigger the extension)Project.toml
of the docs (because that's the backend I want to use there)If I see this right, they are doing basically the same (bit more complicated though because they need GraphMakie
)
https://github.com/bsc-quantic/Tenet.jl/blob/master/ext/TenetGraphMakieExt.jl
@navidcy Okay, I got it to work
julia> using SpeedyWeather
julia> heatmap
ERROR: UndefVarError: `heatmap` not defined
julia> using CairoMakie
Precompiling SpeedyWeatherMakieExt
1 dependency successfully precompiled in 12 seconds. 360 already precompiled.
julia> methods(heatmap)
# 4 methods for generic function "heatmap" from MakieCore:
[1] heatmap()
@ ~/.julia/packages/MakieCore/UAwps/src/recipes.jl:172
[2] heatmap(grid::SpeedyWeather.RingGrids.AbstractFullGrid; title)
@ SpeedyWeatherMakieExt ~/.julia/packages/SpeedyWeather/kXPNB/ext/SpeedyWeatherMakieExt.jl:14
[3] heatmap(grid::SpeedyWeather.RingGrids.AbstractGrid; title)
@ SpeedyWeatherMakieExt ~/.julia/packages/SpeedyWeather/kXPNB/ext/SpeedyWeatherMakieExt.jl:6
[4] heatmap(args...; kw...)
@ ~/.julia/packages/MakieCore/UAwps/src/recipes.jl:175
julia> heatmap(rand(FullGaussianGrid,4))
pops up a CairoMakie window
Lessons learned
Makie
which is also imported when using CairoMakie
(which imports Makie). That way we define the function once but the user can still have any backendusing .SpeedyWeather
is in the SpeedyWeather environment, which isn't supposed to have a hard dependency on Makie (=it's not there) so ever using CairoMakie
will try and add this dependency to the environment (which is exactly not what we want(@v1.10) pkg> add https://github.com/SpeedyWeather/SpeedyWeather.jl#mk/makie
is the way to go as it'll detect the extension correctly without requiring Makie, but then CairoMakie is installed in that environment and using CairoMakie
will then also precompile and import the extension@SimonDanisch I've struggled with this ☝🏼 as I haven't found any info. The pkg docs only describe extensions from the perspective if Makie would want to define some of its plotting functions for external types, not the probably more common use case (?) that a package owns a type and wants to define some plotting function (owned by Makie) for it. If you want me to write this up as a quick guide in the makie docs let me know where and I'm happy to add it.
@milankl would be amazing to have this in the docs.
I think @jkrumbiegel thought about having a section in the docs for this, maybe he has some thoughts.
Otherwise I'd say make a new page for package extensions in how-to
:
https://docs.makie.org/stable/how-to/
https://github.com/MakieOrg/Makie.jl/tree/master/docs/how-to
@simondanisch you're probably happy to see this! @navidcy getting there #482
yields