# Label of Ticks are overlaying

I have a little problem that's driving me crazy. The problem will be clear from the graphic: the text of the tick labels. on the Y-Axis are crossing/overlaying.

I tried everything but I found nothing that could fix this problem.

For anyone interested, here's the code:

 Plot[{1/(5*x)}, {x, 1.8, 6},
GridLines -> {{{4, Red}, {3.5, Red}}, None},
AxesLabel -> {L, W/P},
Ticks -> {None, {{0.049, W/Subscript[P, 2]}, {0.057,
W/Subscript[P, 1]}}},
TicksStyle -> Tiny,
PlotRange -> {0.02, 0.12},
AxesOrigin -> {1, 0.02},


I would be really really glad if someone had a solution for this!

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. Apr 21, 2015 at 23:03
• The ticks are close enough in location that you'll either need to tinker with imagesize, aspect ratio, or use a string for the tick ("W/...") using the editing functions to subscript - that will give to much more vertical room.
– ciao
Apr 21, 2015 at 23:13
• try Ticks -> {None, {{0.049, Style[Row[{"W / ", Subscript[P, 2]}], 14]}, {0.057, Style[Row[{"W / ", Subscript[P, 1]}], 15]}}}?
– kglr
Apr 22, 2015 at 0:16
• Thank you very much. I tried to find a way to make the fraction smaller, but there seems no way in Mathematica. I did it your way now. Apr 22, 2015 at 1:29

Wrapping your tick labels in DisplayForm[AdjustmentBox[...]]) and setting the BoxBaselineShift option will move the labels vertically so they don't clash. Positive numbers for this option move the content down; negative numbers move it up. According to the documentation, the units are x-heights, but for this example, I found I needed numbers larger than 1. This was a bit surprising but might be because Mathematica is taking the x-height from the smaller font size of the fraction, not from normal text.

Plot[{1/(5*x)}, {x, 1.8, 6},
GridLines -> {{{4, Red}, {3.5, Red}}, None}, AxesLabel -> {L, W/P},
Ticks -> {None, {{0.049,
DisplayForm@
BoxBaselineShift -> 9]}, {0.057,
DisplayForm@
TicksStyle -> Tiny, PlotRange -> {0.02, 0.12},
AxesOrigin -> {1, 0.02}, AxesStyle -> Arrowheads[0.04]]


Re-using the trick from this answer

Plot[{1/(5*x)}, {x, 1.8, 6},
GridLines -> {{{4, Red}, {3.5, Red}}, None}, AxesLabel -> {L, W/P},
Ticks -> {None, {{0.049,
Style[Pane[Style[W/Subscript[P, 2], 16],
BaselinePosition -> (Bottom -> Top),
FrameMargins -> {{0, 0}, {60, 0}},
ImageMargins -> {{0, 0}, {-60, 0}}]]}, {0.057,
Style[Pane[Style[W/Subscript[P, 1], 16],
BaselinePosition -> (Top -> Bottom),
FrameMargins -> {{0, 0}, {0, 60}},
ImageMargins -> {{0, 0}, {0, -60}}]]}}}, TicksStyle -> Tiny,
PlotRange -> {0.02, 0.12}, AxesOrigin -> {1, 0.02},
AxesStyle -> Arrowheads[0.04], ImageSize -> 500]


Or

Plot[{1/(5*x)}, {x, 1.8, 6},
GridLines -> {{{4, Red}, {3.5, Red}}, None}, AxesLabel -> {L, W/P},
Ticks -> {None, {{0.049,
Style[Row[{"W / ", Subscript[P, 2]}], 14]}, {0.057,
Style[Row[{"W / ", Subscript[P, 1]}], 15]}}}, TicksStyle -> Tiny,
PlotRange -> {0.02, 0.12}, AxesOrigin -> {1, 0.02},
AxesStyle -> Arrowheads[0.04], ImageSize -> 500]