Skip to content

Commit

Permalink
Added way for PolarAxis to pull fontsize attribute from Figure (#4314)
Browse files Browse the repository at this point in the history
* Added way for PolarAxis to pull fontsize attribute from Figure

Adjusted the "rticklabelsize" and "thetaticklabelsize" properties in the "types.jl" file to fall back to inheriting the fontsize from the Figure, if the ticklabelsize is not defined. This fixes issue #3928 (#3928).

* Added reference tests and changes to CHANGELOG.md for PR #4314

* Corrected and moved reference tests

* Removed trailing whitespace

* Changed frontsize inheritance according to discussion in PR #4314

yticklabelsize now propagates into rticklabelsize instead of thetaticklabelsize and xticklabelsize now propagates into thetaticklabelsize

* Added unit tests similar to image reference tests for PolarAxis fontsize

* Removed reference image tests

> Actually I think this would be better as unit tests. There is already a refimg test for decorations that should confirm that changing r-/thetaticklabelsize has the desired effect. So here you just need to confirm that the PolarAxis is correctly inheriting values.

* Made changelog entry message clearer to understand

* Update testset (PolarAxis from Theme) to use correct code for theming

* Fixed indentation issues

* Update CHANGELOG.md

---------

Co-authored-by: Simon <sdanisch@protonmail.com>
Co-authored-by: Frederic Freyer <frederic481994@hotmail.de>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 808d092 commit 4f2971d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed issue with CairoMakie rendering scene backgrounds at the wrong position [#4425](https://github.com/MakieOrg/Makie.jl/pull/4425)
- Fix incorrect inverse transformation in `position_on_plot` for lines, causing incorrect tooltip placement in DataInspector [#4402](https://github.com/MakieOrg/Makie.jl/pull/4402)
- `PolarAxis` font size now defaults to global figure `fontsize` in the absence of specific `Axis` theming [#4314](https://github.com/MakieOrg/Makie.jl/pull/4314)
- `MultiplesTicks` accepts new option `strip_zero=true`, allowing labels of the form `0x` to be `0` [#4372](https://github.com/MakieOrg/Makie.jl/pull/4372)

## [0.21.12] - 2024-09-28
Expand Down
4 changes: 2 additions & 2 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ end
"The formatter for the `r` ticks"
rtickformat = Makie.automatic
"The fontsize of the `r` tick labels."
rticklabelsize::Float32 = inherit(scene, (:Axis, :xticklabelsize), 16)
rticklabelsize::Float32 = inherit(scene, (:Axis, :yticklabelsize), inherit(scene, :fontsize, 16))
"The font of the `r` tick labels."
rticklabelfont = inherit(scene, (:Axis, :xticklabelfont), inherit(scene, :font, Makie.defaultfont()))
"The color of the `r` tick labels."
Expand Down Expand Up @@ -1916,7 +1916,7 @@ end
"The formatter for the `theta` ticks."
thetatickformat = Makie.automatic
"The fontsize of the `theta` tick labels."
thetaticklabelsize::Float32 = inherit(scene, (:Axis, :yticklabelsize), 16)
thetaticklabelsize::Float32 = inherit(scene, (:Axis, :xticklabelsize), inherit(scene, :fontsize, 16))
"The font of the `theta` tick labels."
thetaticklabelfont = inherit(scene, (:Axis, :yticklabelfont), inherit(scene, :font, Makie.defaultfont()))
"The color of the `theta` tick labels."
Expand Down
24 changes: 24 additions & 0 deletions test/PolarAxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,28 @@
ax = PolarAxis(fig[1, 1], radius_at_origin = -1.0, rlimits = (0, 10))
@test ax.scene.transformation.transform_func[].r0 == -1.0
end

@testset "PolarAxis fontsize from Figure()" begin
fig = Figure(fontsize = 50)
ax = PolarAxis(fig[1, 1])
@test ax.rticklabelsize[] == 50
@test ax.thetaticklabelsize[] == 50
end

@testset "PolarAxis fontsize from :Axis" begin
fig = Figure(; Axis = (; xticklabelsize = 35, yticklabelsize = 65))
ax = PolarAxis(fig[1, 1])
@test ax.thetaticklabelsize[] == 35
@test ax.rticklabelsize[] == 65
end

@testset "PolarAxis fontsize from Theme()" begin
fontsize_theme = Theme(fontsize = 10)
with_theme(fontsize_theme) do
fig = Figure()
ax = PolarAxis(fig[1, 1])
@test ax.rticklabelsize[] == 10
@test ax.thetaticklabelsize[] == 10
end
end
end

0 comments on commit 4f2971d

Please sign in to comment.