Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have drawn a triangle using Line graphics primitive and Graphics3D function:

 Graphics3D[Line[{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}}], 
 Axes -> False, Boxed -> True, AspectRatio -> 1]

enter image description here

But in the shape I get, the vertices of triangle do not coincide with the vertices of the box, how can I solve this problem?

share|improve this question
I think you can try PlotRangePadding -> 0 – xslittlegrass May 16 '13 at 5:20
up vote 5 down vote accepted

The comment is right, but here is a thought. If you'd like a cube you should use Cuboid and leave the 3D box for the role it plays - to put things in a better 3D perspective (if needed). Then you precisely control all coordinates. You could try something like

  {Red, Opacity[.7], Polygon[{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]},
  {Opacity[.2], Cuboid[{0, 1, 0}, {1, 0, 1}]}
  }, Axes -> False, Boxed -> False, AspectRatio -> 1]

enter image description here

share|improve this answer
Very nice, thank you very much. – Ahmad A May 16 '13 at 5:55

As noted by xslittlegrass you can get coincident vertices by instructing Graphics3D not to use padding of the plot range, by using PlotRangePadding -> 0.

AspectRatio controls the two dimensional image aspect ratio rather the proportions of the three dimensional rendering which is what I expect you intended; for that use BoxRatios.

Specifying Boxed -> True should (by default) produce a graph without axis lines shown, therefore the Axes -> False option is redundant.

 Line[Tuples[{0, 1}, 3][[{5, 3, 2, 5}]]],
 Boxed -> True,
 PlotRangePadding -> 0

enter image description here

share|improve this answer
Brilliant, thank you very much. – Ahmad A May 16 '13 at 7:16
@Ahmad You're welcome. – Mr.Wizard May 16 '13 at 7:19

Your Answer


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.