2
$\begingroup$

This question already has an answer here:

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.

$\endgroup$

marked as duplicate by Mr.Wizard Oct 29 '14 at 23:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ You could wrap each tick label in Framed and use FrameMargins but seems like a kluge. $\endgroup$ – rivercfd Oct 29 '14 at 13:43
  • $\begingroup$ 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. $\endgroup$ – Mr.Wizard Oct 30 '14 at 0:01
0
$\begingroup$

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]]

enter image description here

$\endgroup$
0
$\begingroup$

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: enter image description here

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. enter image description here

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.