@@ -219,7 +219,7 @@ This may be useful when working in modules or in Pluto notebooks
219219(see the [BSON.jl documentation](https://github.com/JuliaIO/BSON.jl?tab=readme-ov-file#loading-custom-data-types-within-modules)
220220for more detail).
221221
222- ## Caching the results of a sweep
222+ ## Example: Caching the results of a sweep
223223
224224It can be common to need to cache the results of a large sweep (e.g., over parameters or trials of a simulation).
225225
@@ -427,6 +427,33 @@ julia> cache(SUBSET === Colon() ? "fullsweep.bson" : nothing) do
427427```
428428Note that the full cache was not generated here.
429429
430+ ## Example: Caching large Makie figures in Pluto notebooks
431+
432+ Plotting a large amount of data can be quite time-consuming!
433+ The following code shows how a Makie figure can be easily cached
434+ in the context of a Pluto notebook
435+ (similar approaches should be possible in other contexts):
436+
437+ ``` julia
438+ using CacheVariables, CairoMakie
439+ cache(" fig.bson" ) do
440+ fig = Figure()
441+ ax = Axis(fig[1 ,1 ])
442+ for f in 1 : 1000
443+ lines!(ax, sin.(f.* (0 : 0.02pi : 2pi )))
444+ end
445+ HTML(repr(" text/html" , fig))
446+ end
447+ ```
448+
449+ The first time this code is run, it generates the figure
450+ (in HTML form since we are in a Pluto notebook)
451+ and saves the result.
452+
453+ The next time this code is run, it simply
454+ loads and displays the saved HTML representation,
455+ which can be much faster!
456+
430457## Related packages
431458
432459- [Memoization.jl](https://github.com/marius311/Memoization.jl)
0 commit comments