Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm looking for a way to have the axes at the origin in a 3D plot and to label the (x,y,z) axes in the usual way---with x near the end of the drawn portion of the x axis, y near the end of the drawn portion of the y axis, etc. I've tried

Plot3D[x^2 + y^2 + 3, {x, -3, 3}, {y, -3, 3}, 
      AxesOrigin -> {0, 0, 0}, PlotRange -> {-1, 20}, AxesLabel -> {x, y, z}]

which works well for the axes position but horribly for the labeling. (The labels appear all together near the origin; it is not at all clear which axis is associated with which label.) Any suggestions?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

With Scaled position:

Show[{Plot3D[x^2 + y^2 + 3, {x, -3, 3}, {y, -3, 3}, 
      AxesOrigin -> {0, 0, 0}, PlotRange -> {-1, 20}], 
  Graphics3D[{Text["x", Scaled[{-.05, .5, 0}], {0, -1}], 
    Text["y", Scaled[{.5, -.05, 0}], {0, -1}], 
    Text["z", Scaled[{.5, .5, 1.1}]]}]}, Boxed -> False]
share|improve this answer

You can add them manually:

Show[{Plot3D[x^2 + y^2 + 3, {x, -3, 3}, {y, -3, 3}, 
 AxesOrigin -> {0, 0, 0}, PlotRange-> {-1, 20}], 
 Graphics3D[{Text["x", {3, 0, 0}], Text["y", {0, 3, 0}], Text["z", {0, 0, 20}]}]}]

Mess around with the Text[ ] functions to change sizes and positions. I'm sure there must be a better way, though.

share|improve this answer
1  
using Scaled location can help to place labels: Show[{Plot3D[x^2 + y^2 + 3, {x, -3, 3}, {y, -3, 3}, AxesOrigin -> {0, 0, 0}, PlotRange -> {-1, 20}], Graphics3D[{Text["x", Scaled[{-.1, .5, 0}]], Text["y", Scaled[{.5, -.1, 0}]], Text["z", Scaled[{.5, .5, 1.1}]]}]}] –  halmir Mar 18 '13 at 18:41
    
That's a good and scalable (pun not intended) solution. I knew there must be improvements. –  nickjamesuk Mar 18 '13 at 18:48
    
@halmir, please feel free to post that as an answer, too. –  Verbeia Mar 18 '13 at 20:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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