From 7a1774a99a91fd734a172443efa678a9b4510715 Mon Sep 17 00:00:00 2001 From: Tobias Knopp Date: Tue, 10 Oct 2023 15:09:37 +0000 Subject: [PATCH 1/2] add support for CairoMakie --- Project.toml | 1 + src/TensorBoardLogger.jl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Project.toml b/Project.toml index 03f1caf..96bbe8f 100644 --- a/Project.toml +++ b/Project.toml @@ -21,6 +21,7 @@ julia = "1.6" [extras] Cairo = "159f3aea-2a34-519c-b102-8c37f9878175" +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Fontconfig = "186bb1d3-e1f7-5a2c-a377-96d770f13627" Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" diff --git a/src/TensorBoardLogger.jl b/src/TensorBoardLogger.jl index 903eff8..9085097 100644 --- a/src/TensorBoardLogger.jl +++ b/src/TensorBoardLogger.jl @@ -100,6 +100,9 @@ function __init__() @require Plots="91a5bcdd-55d7-5caf-9e0b-520d859cae80" begin include("Optional/Plots.jl") end + @require CairoMakie="13f3f980-e62b-5c42-98c6-ff1f3baf88f0" begin + include("Optional/CairoMakie.jl") + end @require PyPlot="d330b81b-6aea-500a-939a-2ce795aea3ee" begin include("Optional/PyPlot.jl") end From e8fd5a794f244c850499f24f52cd9c6ff8535cc4 Mon Sep 17 00:00:00 2001 From: Tobias Knopp Date: Tue, 10 Oct 2023 15:16:33 +0000 Subject: [PATCH 2/2] add missing file --- src/Optional/CairoMakie.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/Optional/CairoMakie.jl diff --git a/src/Optional/CairoMakie.jl b/src/Optional/CairoMakie.jl new file mode 100644 index 0000000..640f420 --- /dev/null +++ b/src/Optional/CairoMakie.jl @@ -0,0 +1,15 @@ +import .CairoMakie: Figure + +function Base.convert(t::Type{PngImage}, plot::CairoMakie.Figure) + pb = PipeBuffer() + show(pb, MIME("image/png"), plot) + return PngImage(pb) +end + +preprocess(name, plot::CairoMakie.Figure, data) = preprocess(name, convert(PngImage, plot), data) +preprocess(name, plots::AbstractArray{<:CairoMakie.Figure}, data) = begin + for (i, plot)=enumerate(plots) + preprocess(name*"/$i", plot, data) + end + return data +end