From 545f1f01c3480e0322eea9c6a220555d6915ceb1 Mon Sep 17 00:00:00 2001 From: David Hong Date: Sat, 17 Jan 2026 03:33:33 -0500 Subject: [PATCH 1/2] Add example of caching CairoMakie HTML output Fixes #22 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 372235e..f323515 100644 --- a/README.md +++ b/README.md @@ -427,6 +427,33 @@ julia> cache(SUBSET === Colon() ? "fullsweep.bson" : nothing) do ``` Note that the full cache was not generated here. +## Example: Caching large Makie figures in Pluto notebooks + +Plotting a large amount of data can be quite time-consuming! +The following code shows how a Makie figure can be easily cached +in the context of a Pluto notebook +(similar approaches should be possible in other contexts): + +```julia +using CacheVariables, CairoMakie +cache("fig.bson") do + fig = Figure() + ax = Axis(fig[1,1]) + for f in 1:1000 + lines!(ax, sin.(f.*(0:0.02pi:2pi))) + end + HTML(repr("text/html", fig)) +end +``` + +The first time this code is run, it generates the figure +(in HTML form since we are in a Pluto notebook) +and saves the result. + +The next time this code is run, it simply +loads and displays the saved HTML representation, +which can be much faster! + ## Related packages - [Memoization.jl](https://github.com/marius311/Memoization.jl) From 3e61cea3217de9ccb6fcec5b29fbc0c92ef6bd92 Mon Sep 17 00:00:00 2001 From: David Hong Date: Sat, 17 Jan 2026 03:33:49 -0500 Subject: [PATCH 2/2] Tweak README for better organization --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f323515..c98ebd8 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ This may be useful when working in modules or in Pluto notebooks (see the [BSON.jl documentation](https://github.com/JuliaIO/BSON.jl?tab=readme-ov-file#loading-custom-data-types-within-modules) for more detail). -## Caching the results of a sweep +## Example: Caching the results of a sweep It can be common to need to cache the results of a large sweep (e.g., over parameters or trials of a simulation).