Skip to content

Commit

Permalink
Add better docs for Axis3 protrusions (#3139)
Browse files Browse the repository at this point in the history
* Add better docs for Axis3 protrusions

* remove 100

* add background color for easier understanding
  • Loading branch information
jkrumbiegel authored Aug 9, 2023
1 parent cf62375 commit 30e7d79
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/makielayout/blocks/axis3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1137,5 +1137,28 @@ function attribute_examples(::Type{Axis3})
"""
),
],
:protrusions => [
Example(
name = "Single protrusion",
code = """
fig = Figure(backgroundcolor = :gray97)
Box(fig[1, 1], strokewidth = 0) # visualizes the layout cell
Axis3(fig[1, 1], protrusions = 100, viewmode = :stretch,
title = "protrusions = 100")
fig
"""
),
Example(
name = "Removing protrusions",
code = """
fig = Figure(backgroundcolor = :gray97)
Box(fig[1, 1], strokewidth = 0) # visualizes the layout cell
ax = Axis3(fig[1, 1], protrusions = (0, 0, 0, 20), viewmode = :stretch,
title = "protrusions = (0, 0, 0, 20)")
hidedecorations!(ax)
fig
"""
),
]
)
end
14 changes: 13 additions & 1 deletion src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,19 @@ end
ygridvisible = true
"Controls if the z grid is visible"
zgridvisible = true
"The protrusions on the sides of the axis, how much gap space is reserved for labels etc."
"""
The protrusions control how much gap space is reserved for labels etc. on the sides of the `Axis3`.
Unlike `Axis`, `Axis3` currently does not set these values automatically depending on the properties
of ticks and labels. This is because the effective protrusions also depend on the rotation and scaling
of the axis cuboid, which changes whenever the `Axis3` shifts in the layout. Therefore, auto-updating
protrusions could lead to an endless layout update cycle.
The default value of `30` for all sides is just a heuristic and might lead to collisions of axis
decorations with the `Figure` boundary or other plot elements. If that's the case, you can try increasing
the value(s).
The `protrusions` attribute accepts a single number for all sides, or a tuple of `(left, right, bottom, top)`.
"""
protrusions = 30
"The x ticks"
xticks = WilkinsonTicks(5; k_min = 3)
Expand Down

0 comments on commit 30e7d79

Please sign in to comment.