Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jk/axis elements #2527

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ function initialize_block!(ax::Axis; palette = nothing)

topscene = ax.blockscene

decorations = Dict{Symbol, Any}()
elements = Dict{Symbol, Any}()
ax.elements = elements

if palette === nothing
palette = haskey(topscene.theme, :palette) ? deepcopy(topscene.theme[:palette]) : copy(Makie.default_palettes)
Expand Down Expand Up @@ -208,7 +209,7 @@ function initialize_block!(ax::Axis; palette = nothing)
# so it doesn't rasterize the scene
background = poly!(topscene, scenearea; color=ax.backgroundcolor, inspectable=false, shading=false, strokecolor=:transparent)
translate!(background, 0, 0, -100)
decorations[:background] = background
elements[:background] = background

block_limit_linking = Observable(false)
setfield!(ax, :block_limit_linking, block_limit_linking)
Expand All @@ -223,7 +224,7 @@ function initialize_block!(ax::Axis; palette = nothing)
)
# put gridlines behind the zero plane so they don't overlay plots
translate!(xgridlines, 0, 0, -10)
decorations[:xgridlines] = xgridlines
elements[:xgridlines] = xgridlines

xminorgridnode = Observable(Point2f[]; ignore_equal_values=true)
xminorgridlines = linesegments!(
Expand All @@ -232,7 +233,7 @@ function initialize_block!(ax::Axis; palette = nothing)
)
# put gridlines behind the zero plane so they don't overlay plots
translate!(xminorgridlines, 0, 0, -10)
decorations[:xminorgridlines] = xminorgridlines
elements[:xminorgridlines] = xminorgridlines

ygridnode = Observable(Point2f[]; ignore_equal_values=true)
ygridlines = linesegments!(
Expand All @@ -241,7 +242,7 @@ function initialize_block!(ax::Axis; palette = nothing)
)
# put gridlines behind the zero plane so they don't overlay plots
translate!(ygridlines, 0, 0, -10)
decorations[:ygridlines] = ygridlines
elements[:ygridlines] = ygridlines

yminorgridnode = Observable(Point2f[]; ignore_equal_values=true)
yminorgridlines = linesegments!(
Expand All @@ -250,7 +251,7 @@ function initialize_block!(ax::Axis; palette = nothing)
)
# put gridlines behind the zero plane so they don't overlay plots
translate!(yminorgridlines, 0, 0, -10)
decorations[:yminorgridlines] = yminorgridlines
elements[:yminorgridlines] = yminorgridlines

onany(ax.xscale, ax.yscale) do xsc, ysc
scene.transformation.transform_func[] = (xsc, ysc)
Expand Down Expand Up @@ -387,13 +388,13 @@ function initialize_block!(ax::Axis; palette = nothing)
xoppositeline = linesegments!(topscene, xoppositelinepoints, linewidth = ax.spinewidth,
visible = xoppositespinevisible, color = xoppositespinecolor, inspectable = false,
linestyle = nothing)
decorations[:xoppositeline] = xoppositeline
elements[:xoppositeline] = xoppositeline
translate!(xoppositeline, 0, 0, 20)

yoppositeline = linesegments!(topscene, yoppositelinepoints, linewidth = ax.spinewidth,
visible = yoppositespinevisible, color = yoppositespinecolor, inspectable = false,
linestyle = nothing)
decorations[:yoppositeline] = yoppositeline
elements[:yoppositeline] = yoppositeline
translate!(yoppositeline, 0, 0, 20)

onany(xaxis.tickpositions, scene.px_area) do tickpos, area
Expand Down Expand Up @@ -468,7 +469,7 @@ function initialize_block!(ax::Axis; palette = nothing)
lineheight = ax.titlelineheight,
markerspace = :data,
inspectable = false)
decorations[:title] = titlet
elements[:title] = titlet

map!(compute_protrusions, ax.layoutobservables.protrusions, ax.title, ax.titlesize, ax.titlegap, ax.titlevisible, ax.spinewidth,
ax.topspinevisible, ax.bottomspinevisible, ax.leftspinevisible, ax.rightspinevisible,
Expand Down
1 change: 1 addition & 0 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ end
interactions::Dict{Symbol, Tuple{Bool, Any}}
xaxis::LineAxis
yaxis::LineAxis
elements::Dict{Symbol, Any}
@attributes begin
"The xlabel string."
xlabel = ""
Expand Down