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

pass current_figure() or current_axis() to functions by default #4519

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/figures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
Once resized, all content should fit the available space, including
the `Figure`'s outer padding.
"""
function resize_to_layout!(fig::Figure)
function resize_to_layout!(fig::Figure = current_figure())

Check warning on line 184 in src/figures.jl

View check run for this annotation

Codecov / codecov/patch

src/figures.jl#L184

Added line #L184 was not covered by tests
# it is assumed that all plot objects have been added at this point,
# but it's possible the limits have not been updated, yet,
# so without `update_state_before_display!` it's possible that the layout
Expand Down
17 changes: 9 additions & 8 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,8 @@
return lims
end

xautolimits(ax::Axis) = autolimits(ax, 1)
yautolimits(ax::Axis) = autolimits(ax, 2)
xautolimits(ax::Axis = current_axis()) = autolimits(ax, 1)
yautolimits(ax::Axis = current_axis()) = autolimits(ax, 2)

"""
linkaxes!(a::Axis, others...)
Expand Down Expand Up @@ -1101,7 +1101,7 @@
Hide decorations of the x-axis: label, ticklabels, ticks and grid. Keyword
arguments can be used to disable hiding of certain types of decorations.
"""
function hidexdecorations!(la::Axis; label = true, ticklabels = true, ticks = true, grid = true,
function hidexdecorations!(la::Axis = current_axis(); label = true, ticklabels = true, ticks = true, grid = true,
minorgrid = true, minorticks = true)
if label
la.xlabelvisible = false
Expand Down Expand Up @@ -1130,7 +1130,7 @@
Hide decorations of the y-axis: label, ticklabels, ticks and grid. Keyword
arguments can be used to disable hiding of certain types of decorations.
"""
function hideydecorations!(la::Axis; label = true, ticklabels = true, ticks = true, grid = true,
function hideydecorations!(la::Axis = current_axis(); label = true, ticklabels = true, ticks = true, grid = true,
minorgrid = true, minorticks = true)
if label
la.ylabelvisible = false
Expand Down Expand Up @@ -1161,7 +1161,7 @@

See also [`hidexdecorations!`], [`hideydecorations!`], [`hidezdecorations!`]
"""
function hidedecorations!(la::Axis; label = true, ticklabels = true, ticks = true, grid = true,
function hidedecorations!(la::Axis = current_axis(); label = true, ticklabels = true, ticks = true, grid = true,
minorgrid = true, minorticks = true)
hidexdecorations!(la; label = label, ticklabels = ticklabels, ticks = ticks, grid = grid,
minorgrid = minorgrid, minorticks = minorticks)
Expand Down Expand Up @@ -1191,13 +1191,14 @@
end
end
end
hidespines!(spines::Symbol...) = hidespines!(current_axis(), spines...)

Check warning on line 1194 in src/makielayout/blocks/axis.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/blocks/axis.jl#L1194

Added line #L1194 was not covered by tests

"""
space = tight_yticklabel_spacing!(ax::Axis)

Sets the space allocated for the yticklabels of the `Axis` to the minimum that is needed and returns that value.
"""
function tight_yticklabel_spacing!(ax::Axis)
function tight_yticklabel_spacing!(ax::Axis = current_axis())

Check warning on line 1201 in src/makielayout/blocks/axis.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/blocks/axis.jl#L1201

Added line #L1201 was not covered by tests
space = tight_ticklabel_spacing!(ax.yaxis)
return space
end
Expand All @@ -1207,7 +1208,7 @@

Sets the space allocated for the xticklabels of the `Axis` to the minimum that is needed and returns that value.
"""
function tight_xticklabel_spacing!(ax::Axis)
function tight_xticklabel_spacing!(ax::Axis = current_axis())

Check warning on line 1211 in src/makielayout/blocks/axis.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/blocks/axis.jl#L1211

Added line #L1211 was not covered by tests
space = tight_ticklabel_spacing!(ax.xaxis)
return space
end
Expand All @@ -1217,7 +1218,7 @@

Sets the space allocated for the xticklabels and yticklabels of the `Axis` to the minimum that is needed.
"""
function tight_ticklabel_spacing!(ax::Axis)
function tight_ticklabel_spacing!(ax::Axis = current_axis())

Check warning on line 1221 in src/makielayout/blocks/axis.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/blocks/axis.jl#L1221

Added line #L1221 was not covered by tests
tight_xticklabel_spacing!(ax)
tight_yticklabel_spacing!(ax)
return
Expand Down
Loading