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

Consider visible in PolarAxis protrusions #4823

Merged
merged 4 commits into from
Feb 25, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Reverted change to `poly` which disallowed 3D geometries from being plotted [#4738](https://github.com/MakieOrg/Makie.jl/pull/4738)
- Enabled autocompletion on Block types, e.g. `?Axis.xti...` [#4786](https://github.com/MakieOrg/Makie.jl/pull/4786)
- Added `dpi` metadata to all rendered png files, where `px_per_unit = 1` means 96dpi, `px_per_unit = 2` means 192dpi, and so on. This gives frontends a chance to show plain Makie png images with the correct scaling [#4812](https://github.com/MakieOrg/Makie.jl/pull/4812).
- Fixed issue with `PolarAxis` not considering tick visibility in protrusion calculations. [#4823](https://github.com/MakieOrg/Makie.jl/pull/4823)

## [0.22.1] - 2025-01-17

Expand Down
39 changes: 18 additions & 21 deletions ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,37 +233,25 @@ end
fig
end

@reference_test "PolarAxis surface" begin
f = Figure()
ax = PolarAxis(f[1, 1])
zs = [r*cos(phi) for phi in range(0, 4pi, length=100), r in range(1, 2, length=100)]
p = surface!(ax, 0..2pi, 0..10, zs, shading = NoShading, colormap = :coolwarm, colorrange=(-2, 2))
rlims!(ax, 0, 11) # verify that r = 10 doesn't end up at r > 10
translate!(p, 0, 0, -200)
Colorbar(f[1, 2], p)
f
end

# may fail in WGLMakie due to missing dashes
@reference_test "PolarAxis scatterlines spine" begin
f = Figure(size = (800, 400))
@reference_test "PolarAxis decorations" begin
# may fail in WGLMakie due to missing dashes
# tests: some decorations, theta_as_x, title, scatter, lines
f = Figure(size = (800, 800), backgroundcolor = :gray)
ax1 = PolarAxis(f[1, 1], title = "No spine", spinevisible = false, theta_as_x = false)
scatterlines!(ax1, range(0, 1, length=100), range(0, 10pi, length=100), color = 1:100)

ax2 = PolarAxis(f[1, 2], title = "Modified spine")
ax2.spinecolor[] = :red
ax2.spinestyle[] = :dash
ax2.spinewidth[] = 5
rlims!(ax2, 0, 1.5)
scatterlines!(ax2, range(0, 10pi, length=100), range(0, 1, length=100), color = 1:100)
f
end

# may fail in CairoMakie due to different text stroke handling
# and in WGLMakie due to missing stroke
@reference_test "PolarAxis decorations" begin
f = Figure(size = (400, 400), backgroundcolor = :black)
# may fail in CairoMakie due to different text stroke handling
# and in WGLMakie due to missing stroke
# tests: decorations
ax = PolarAxis(
f[1, 1],
f[2, 1],
backgroundcolor = :black,
rminorgridvisible = true, rminorgridcolor = :red,
rminorgridwidth = 1.0, rminorgridstyle = :dash,
Expand All @@ -278,6 +266,15 @@ end
thetaticks = ([0, π/2, π, 3π/2], ["A", "B", "C", rich("D", color = :orange)]), # https://github.com/MakieOrg/Makie.jl/issues/3583
rticks = ([0.0, 2.5, 5.0, 7.5, 10.0], ["0.0", "2.5", "5.0", "7.5", rich("10.0", color = :orange)])
)

# tests: surface, grid layering, hidedecorations!() effect on spacing
ax = PolarAxis(f[2, 2], gridz = 1, backgroundcolor = :lightblue)
hidedecorations!(ax)
ax.rgridvisible[] = true
ax.thetagridvisible[] = true
zs = [r*cos(phi) for phi in range(0, 4pi, length=100), r in range(1, 2, length=100)]
p = surface!(ax, 0..2pi, 0..10, zeros(size(zs)), color = zs, shading = NoShading, colormap = :coolwarm, colorrange=(-2, 2))
rlims!(ax, 0, 11) # verify that r = 10 doesn't end up at r > 10
f
end

Expand Down
20 changes: 13 additions & 7 deletions src/makielayout/blocks/polaraxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,30 @@ function initialize_block!(po::PolarAxis; palette=nothing)
rticklabelplot.plots[1].text,
rticklabelplot.plots[1].fontsize,
rticklabelplot.plots[1].font,
rticklabelplot.visible,
po.rticklabelpad,
thetaticklabelplot.plots[1].text,
thetaticklabelplot.plots[1].fontsize,
thetaticklabelplot.plots[1].font,
thetaticklabelplot.visible,
po.thetaticklabelpad,
po.overlay.viewport
) do _, _, _, rpad, _, _, _, tpad, area
) do _, _, _, rvisible, rpad, _, _, _, tvisible, tpad, area

# get maximum size of tick label
# (each boundingbox represents a string without text.position applied)
max_widths = Vec2f(0)
for gc in thetaticklabelplot.plots[1].plots[1][1][]
bbox = string_boundingbox(gc, Quaternionf(0, 0, 0, 1)) # no rotation
max_widths = max.(max_widths, widths(bbox)[Vec(1,2)])
if tvisible
for gc in thetaticklabelplot.plots[1].plots[1][1][]
bbox = string_boundingbox(gc, Quaternionf(0, 0, 0, 1)) # no rotation
max_widths = max.(max_widths, widths(bbox)[Vec(1,2)])
end
end
for gc in rticklabelplot.plots[1].plots[1][1][]
bbox = string_boundingbox(gc, Quaternionf(0, 0, 0, 1)) # no rotation
max_widths = max.(max_widths, widths(bbox)[Vec(1,2)])
if rvisible
for gc in rticklabelplot.plots[1].plots[1][1][]
bbox = string_boundingbox(gc, Quaternionf(0, 0, 0, 1)) # no rotation
max_widths = max.(max_widths, widths(bbox)[Vec(1,2)])
end
end

max_width, max_height = max_widths
Expand Down
Loading