[Makie] Get current theme

When using with_theme, the first argument is a theme, and keyword arguments modify the given theme. This is great if I have a variable bound to the current theme, and I want to make a modification to it only for the following block. But I do not have a variable bound to the current theme.

Is there a way to get a handle to the current theme? Something like current_figure and current_axis, just for theme.

I think it’s Makie.current_default_theme()

2 Likes

It is, thanks!

I searched through the name of exported names of GLMakie for “theme”, and ofc did not find anything. Perhaps this should be documented in the theming section, and in the docstring for with_theme?

1 Like

Or how about making Makie.current_default_theme() the default theme (first argument to with_theme) if none is provided? This would provide a seamless interface to making adjustments on the current theme for a given group of plots.

1 Like

For some reason, the following was not updating the current_theme:

with_theme(Makie.current_default_theme(); fontsize=20) do
	scatter(1:10, 2:2:20)
end

Instead I had to:

theme = Dict(Makie.current_default_theme())
theme[:fontsize] = 20
	
with_theme(; theme...) do
	scatter(1:10, 2:2:20)
end
1 Like