Skip to main content

plotting - Vertical alignment of FrameTicks Text



The text box of a FrameTick/Tick is, by default, vertically centered on the tick mark.


Illustrating alignment of FrameTicks textbox


Is there a way to adjust the vertical alignment of FrameTick text? Specifically, along the lines of Baseline, Top, etc.


FrameTicksStyle in combination with TextAlignment/Alignment does nothing.



Answer



Using Pane as in Szabolcs's answer or Framed (with FrameStyle->None) with a combination of settings for BaselinePosition, ImageMargins and FrameMargins:


  Graphics[Circle[], Frame -> True, 
FrameTicks -> {{
{{0, Style[Pane[Style[0.4, FontSize -> 48],
BaselinePosition -> (Top -> Bottom),

FrameMargins -> {{0, 0}, {0, 40}},
ImageMargins -> {{0, 0}, {0, -40}}],
Background -> Green]}},
{{0, Style[Pane[Style[0.4, FontSize -> 48],
BaselinePosition -> (Bottom -> Top),
FrameMargins -> {{0, 0}, {40, 0}},
ImageMargins -> {{0, 0}, {-40, 0}}],
Background -> Green]}}}, {None, None}}]

you get



enter image description here


Comments