Skip to content

Commit

Permalink
also fix rtick padding
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Aug 14, 2023
1 parent 56283b6 commit 50d60fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/makielayout/blocks/polaraxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,19 @@ function draw_axis!(po::PolarAxis, axis_radius)

onany(
po.blockscene,
po.rticks, po.rminorticks, po.rtickformat,
po.rticks, po.rminorticks, po.rtickformat, po.rticklabelpad,
po.rtickangle, po.target_radius, axis_radius, po.sample_density,
) do rticks, rminorticks, rtickformat, rtickangle, data_radius, axis_radius, sample_density
po.overlay.px_area
) do rticks, rminorticks, rtickformat, px_pad, rtickangle, data_radius, axis_radius, sample_density, pixelarea

_rtickvalues, _rticklabels = Makie.get_ticks(rticks, identity, rtickformat, 0, data_radius)
_rtickpos = _rtickvalues .* (axis_radius / data_radius) # we still need the values
rtick_pos_lbl[] = tuple.(_rticklabels, Point2f.(_rtickpos, rtickangle))
pad = let
w2, h2 = (0.5 .* widths(pixelarea)).^2
s, c = sincos(rtickangle)
axis_radius * px_pad / sqrt(w2 * c * c + h2 * s * s)
end
rtick_pos_lbl[] = tuple.(_rticklabels, Point2f.(_rtickpos .+ pad, rtickangle))

thetas = LinRange(thetalims..., sample_density)
rgridpoints[] = Makie.GeometryBasics.LineString.([Point2f.(r, thetas) for r in _rtickpos])
Expand Down Expand Up @@ -249,7 +255,11 @@ function draw_axis!(po::PolarAxis, axis_radius)
color = po.rticklabelcolor,
strokewidth = po.rticklabelstrokewidth,
strokecolor = rstrokecolor,
align = (:left, :bottom),
align = map(po.direction, po.theta_0, po.rtickangle) do dir, theta_0, angle
s, c = sincos(dir * (angle + theta_0))
scale = 1 / max(abs(s), abs(c)) # point on ellipse -> point on bbox
Point2f(0.5 - 0.5scale * c, 0.5 - 0.5scale * s)
end
)

thetastrokecolor = map(po.blockscene, clipcolor, po.thetaticklabelstrokecolor) do bg, sc
Expand Down
2 changes: 2 additions & 0 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,8 @@ end
rticklabelstrokewidth = 0.0
"The color of the outline of `r` ticks. By default this uses the background color."
rticklabelstrokecolor = automatic
"Padding of the `r` ticks label."
rticklabelpad = 4f0
"Controls if the `r` ticks are visible."
rticklabelsvisible = inherit(scene, (:Axis, :xticklabelsvisible), true)
"The angle in radians along which the `r` ticks are printed."
Expand Down

0 comments on commit 50d60fb

Please sign in to comment.