Include more padding between tick marks and plot [duplicate]

How can I modify the code below to add some padding between my tick marks and 3D plot? It is not a problem in this example, but often my tick marks collide with my axes.

r = Norm[{x, y}];
Plot3D[r^2, {x, -Pi, Pi}, {y, -Pi, Pi}, TicksStyle -> Large]


Apologies if trivial question.

• You could wrap each tick label in Framed and use FrameMargins but seems like a kluge. Oct 29, 2014 at 13:43
• This quesiton appears to be a duplicate so I have marked it as such. Please read the question linked at the top of your post as well as its answers. If you feel that your question is not the same please edit it to clarify in what way it is different. If the question is the same but the answers are unsatisfactory please explain that as well. Oct 30, 2014 at 0:01

Try this:

 r = Norm[{x, y}];
Plot3D[r^2, {x, -Pi, Pi}, {y, -Pi, Pi},
Ticks -> {{{-2, " -2 "}, {0, " 0 "}, {2, " 2 "}}, {{-2, " -2 "}, {0,
" 0 "}, {2, " 2 "}}, {{0, "0 "}, {10, "10 "}, {20, "20 "}}},
TicksStyle -> Large]


giving this:

Have fun!

Then try this:

     r = Norm[{x, y}];
sp = Spacer[20];
lst = {{{-2, "-2"}, {0, "0"}, {2, "2"}}, {{-2, "-2"}, {0, "0"}, {2,
"2"}}, {{0, "0"}, {10, "10"}, {20, "20"}}};

Plot3D[r^2, {x, -Pi, Pi}, {y, -Pi, Pi},
Ticks -> Map[ReplaceAll[#, {x_, y_} -> {x, Row[{sp, y, sp}]}] &,
lst], TicksStyle -> Large]


and play with the argument of the Spacer.

• Unfortunately this doesn't solve my problem. I want to specify how much padding there is. Thanks though :)
– Tom
Oct 29, 2014 at 14:22

You can wrap the tick labels with Pane and adjust the distances from the axes using the FrameMargins settings.

ClearAll[lF];
lF[l_:0, r_:0, t_:0, b_:0] := Pane[Style[#, FontSize->Large],
FrameMargins->{{l, r}, {t, b}}] &;

r = Norm[{x, y}];

Row[{Plot3D[r^2, {x, -Pi, Pi}, {y, -Pi, Pi}, ImageSize -> 500,TicksStyle -> Large,
Ticks -> {{#, #} & /@ {-2, 0, 2}, {#, #} & /@ {-2, 0, 2},
{#, lF[0, 20, 0, 0]@#} & /@ Range[0, 20, 5]}],
Plot3D[r^2, {x, -Pi, Pi}, {y, -Pi, Pi}, ImageSize -> 500,TicksStyle -> Large,
Ticks -> {{#, #} & /@ {-2, 0, 2}, {#, lF[20, 0]@#} & /@ {-2, 0, 2},
{#, lF[0, 50, 0, 0]@#} & /@ Range[0, 20, 5]}]}, Spacer[5]]