21
$\begingroup$

Is there any way to tell Mathematica 7 to use "traditional" axes rather than boxing a three-dimensional graph? That is, rather than the default view produced by

Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2},Boxed->False], alt text

I would like three "axis arrows" to emanate from the origin.

$\endgroup$

2 Answers 2

12
$\begingroup$

In the end, I ended up writing my own arrow routine, which produces scalable arrowheads and scalable labels:

axes[x_, y_, z_, f_, a_] := Graphics3D[ Join[{Arrowheads[a]}, Arrow[{{0, 0, 0}, #}] & /@ {{x, 0, 0}, {0, y, 0}, {0, 0, z}}, { Text[Style["x", FontSize -> Scaled[f]], {0.9*x, 0.1*y, 0.1*z}], Text[Style["y", FontSize -> Scaled[f]], {0.1 x, 0.9*y, 0.1*z}], Text[Style["z", FontSize -> Scaled[f]], {0.1*x, 0.1*y, 0.9*z}]}]]

The arguments are the x, y, and z positions of the x, y, and z arrows, respectively, f is the font scale (try about 0.05), and a is the arrowhead scale (about 0.05 should do it). This is combined with ordinary 3D graphics using Show[], as in

Show[Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, Boxed -> False, PlotStyle -> Opacity[0.7], Mesh -> 4, Axes -> None], axes[2.5, 2.5, 1.5, 0.05, 0.02], PlotRange -> {{-3, 3}, {-3, 3}, {0, 1.5}}]

The resulting plot is

alt text

$\endgroup$
0
8
$\begingroup$

You need the AxesOrigin Option.

Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2},Boxed->False, AxesOrigin->{0,0,0}]

I misinterpreted your question in an earlier answer and I was suggesting using the "AxesEdge" Option which changes the sides of the bounding box on which the axes are displayed. However, you might still find that useful:

Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, Boxed -> False, AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}}]

$\endgroup$
5
  • $\begingroup$ That's 50% of what I'm looking for - do you know if it's possible to cut off the negative bits, so that the axes are rays instead of lines? $\endgroup$
    – JRG
    Jan 5, 2011 at 23:02
  • $\begingroup$ @Josh Guffin: Do you need numbers on the axes? $\endgroup$
    – Henry B.
    Jan 5, 2011 at 23:22
  • $\begingroup$ In general no, but I would like them to be drawn by the system rather than adding them in by hand (with Graphics[] directives); I don't want to have to specify the length of the arrows every time. $\endgroup$
    – JRG
    Jan 5, 2011 at 23:25
  • $\begingroup$ @Josh Guffin: Yes. You read my mind. I think you can use the Scaled command to fix the size of relative size of the arrows. $\endgroup$
    – Henry B.
    Jan 5, 2011 at 23:51
  • $\begingroup$ "Traditional axes" to me sounds like the way mathematicians would typically sketch a 3D plot, no just with axes emanating from the origin, but with arrows at their positive ends and axis labels, too. $\endgroup$
    – murray
    May 1, 2015 at 1:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .