-
-
Notifications
You must be signed in to change notification settings - Fork 374
Open
Labels
Description
My understanding is that the attributes set in with_theme(...) remains effective only in the do ... end block following it. However, some attributes seem to leak out of the with_theme(...) do ... end block and affect plotting outside the block.
Here is an MWE:
using CairoMakie
# Define a theme with `aspect`.
theme = Theme(; Axis=(; aspect=DataAspect()))
# Verify that the default theme does not have `aspect` set up.
@show Makie.current_default_theme().Axis # Attributes with 0 entries
# Plot with the theme.
fig = Figure()
with_theme(theme) do
ax = Axis(fig[1,1])
heatmap!(ax, 1:10, 1:10, rand(10,10))
end
# Now, the default theme has `aspect` set up.
@show Makie.current_default_theme().Axis # Attributes with 1 entry: aspect => DataAspect()
# Because `aspect = DataAspect()` is set, the following plot, whose y-data is
# 1/1000 of x-data, is squashed along the y-direction completely.
fig = Figure()
ax = Axis(fig[1,1])
xs = 1:10
ys = 0.001 * xs
scatterlines!(ax, xs, ys)
display(fig)Here is the vertically squashed plot generated by the above script:

I tried other attributes of Axis in with_theme(...) as well, such as xlabel and ylabel, and all of them survive outside the with_theme(...) do ... end block. Is this an expected behavior?
Here is the version information:
julia> VERSION
v"1.12.4"
(@v1.12) pkg> st CairoMakie
Status `~/.julia/environments/v1.12/Project.toml`
[13f3f980] CairoMakie v0.15.8
(@v1.12) pkg> st Makie
Status `~/.julia/environments/v1.12/Project.toml`
[ee78f7c6] Makie v0.24.8Reactions are currently unavailable