Skip to content

Commit

Permalink
refactor: improve pretty_legend!
Browse files Browse the repository at this point in the history
  • Loading branch information
Beforerr committed Nov 10, 2024
1 parent 4ecaaba commit aadcd87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/makie/makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@ end
# -----
# Position
# -----

default_titleposition(position) = position in [:top, :bottom] ? :left : :top

"""
guides_position(f, position)
Return the position of the guides for the given `position` in the `f`.
Return the position of the guides (like colorbar) for the given `position` in the `f`.
"""
function guides_position(f, position)
@match Symbol(position) begin
Expand Down
5 changes: 3 additions & 2 deletions src/utils/aog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ cdraw!(f::Union{GridPosition,GridSubposition}, args...; kw...) = cdraw!(GridLayo


"""Add a legend to the figure grid `fg`, with the default legend positioned at the top"""
function pretty_legend!(fg::FigureGrid; position=:top, titleposition=default_titleposition(position), kwargs...)
legend!(fg; position=position, titleposition=titleposition, kwargs...)
function pretty_legend!(fg::FigureGrid; position=:top, kwargs...)
titleposition = position in (:top, :bottom) ? :left : :top
legend!(fg; position, titleposition, kwargs...)
end

"""Add a legend to the figure"""
Expand Down

0 comments on commit aadcd87

Please sign in to comment.