GR: fix alignment of ticks label when rotating (#3587)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>
This commit is contained in:
t-bltg 2021-06-30 09:30:55 +02:00 committed by GitHub
parent 7b0066c433
commit a64ae3d13c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -651,12 +651,17 @@ end
function gr_set_tickfont(sp, letter)
axis = sp[Symbol(letter, :axis)]
# invalidate alignment changes for small rotations (|θ| < 45°)
trigger(rot) = abs(sind(rot)) < abs(cosd(rot)) ? 0 : sign(rot)
rot = axis[:rotation]
if letter === :x || (RecipesPipeline.is3d(sp) && letter === :y)
halign = (:left, :hcenter, :right)[sign(axis[:rotation]) + 2]
valign = (axis[:mirror] ? :bottom : :top)
halign = (:left, :hcenter, :right)[trigger(rot) + 2]
valign = (axis[:mirror] ? :bottom : :top, :vcenter)[trigger(abs(rot)) + 1]
else
halign = (axis[:mirror] ? :left : :right)
valign = (:top, :vcenter, :bottom)[sign(axis[:rotation]) + 2]
halign = (axis[:mirror] ? :left : :right, :hcenter)[trigger(abs(rot)) + 1]
valign = (:top, :vcenter, :bottom)[trigger(rot) + 2]
end
gr_set_font(
tickfont(axis),