8
$\begingroup$

I use this code:

ContourPlot3D[x^2 + y^2 + z^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

But I can not to see the coordinate axes inside the sphere like the following picture:

enter image description here

$\endgroup$
2
  • $\begingroup$ Please clarify your question. Do you want your result to have arrows of coordinate axes from the origin, or something else? $\endgroup$
    – kirma
    Commented Aug 13, 2016 at 7:48
  • $\begingroup$ @kirma I want to have arrows of coordinate axes from the origin. $\endgroup$
    – user37694
    Commented Aug 13, 2016 at 7:50

2 Answers 2

13
$\begingroup$

For instance, you can do the following:

Show[Graphics3D[
  MapThread[{Black, Arrow@Tube@{{0, 0, 0}, #1}, 
     Text[#2, #1, {0, -1}]} &, {2 IdentityMatrix[3], {x, y, z}}], 
  Boxed -> False], 
 ContourPlot3D[
  x^2 + y^2 + z^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
  ContourStyle -> Opacity[1/2]]]

enter image description here

$\endgroup$
5
$\begingroup$
Show[



     Graphics3D@{Arrow[{{0, 0, 0}, {1, 0, 0}}]},
     Graphics3D@{Arrow[{{0, 0, 0}, {0, 1, 0}}]},
     Graphics3D@{Arrow[{{0, 0, 0}, {0, 0, 1}}]},


     ContourPlot3D[
         x^2 + y^2 + z^2 == .05,  

        {x, -1, 1}, {y, -1, 1}, {z, -1, 1},

        ContourStyle -> {Green, Opacity[0.1]}, 
        Mesh -> 1,
        MeshStyle -> Red
    ],



    Boxed -> False
]

enter image description here

Graphics3D@{Text[X, {1.1, 0, 0}]},
Graphics3D@{Text[Y, {0, 1.1, 0}]},
Graphics3D@{Text[Z, {0, 0, 1.1}]},

enter image description here

Show[


     Graphics3D@{Arrow[{{0, 0, 0}, {1, 0, 0}}]},   
     Graphics3D@{Arrow[{{0, 0, 0}, {0, 1, 0}}]},
     Graphics3D@{Arrow[{{0, 0, 0}, {0, 0, 1}}]},


     Graphics3D@{Text[X, {1.1, 0, 0}]},
     Graphics3D@{Text[Y, {0, 1.1, 0}]},
     Graphics3D@{Text[Z, {0, 0, 1.1}]},




     ContourPlot3D[
          x^2 + y^2 + z^2 == .05,
         {x, -1, 1}, {y, -1, 1}, {z, -1, 1},

         ContourStyle -> {Green, Opacity[0.3], Specularity[1]},
         Mesh -> 1,
         MeshStyle -> Red
     ],


 Boxed -> False
 ]

enter image description here


Refactored for brevity and with increased PlotPoints:

m = IdentityMatrix[3];

Show[

  Graphics3D[{
    Arrow[{{0, 0, 0}, #} & /@ m],
    FontSize -> 20,
    Thread@Text[{"X", "Y", "Z"}, 1.1 m]
  }],

  ContourPlot3D[
    x^2 + y^2 + z^2 == .05,
    {x, -1, 1}, {y, -1, 1}, {z, -1, 1}
    , ContourStyle -> {Opacity[0.3, Green], Specularity[1]}
    , Mesh -> 1
    , MeshStyle -> Red
    , PlotPoints -> 40
  ]
  , Boxed -> False
]

enter image description here

$\endgroup$
1
  • $\begingroup$ @Mr.Wizard me likey those increased PlotPoints $\endgroup$ Commented Aug 14, 2016 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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