1
$\begingroup$

I need to color each vector into different colors... but this formula just doesn't work:

m = Axes3D[10];
n = ListPointPlot3D[{{4, 5, 6}, {3, -3, -6}, {2, 2, 5}}, 
   PlotLegends -> Automatic, ImageSize -> 400, 
   PlotStyle -> PointSize[0.03], PlotRange -> {-10, 10}];
o = Graphics3D[Arrow[{{4, 5, 6}, {3, -3, -6}}], Axes -> True, 
   Boxed -> False, ColorOutput -> Red](*vector a*);
r = Graphics3D[Arrow[{{4, 5, 6}, {2, 2, 5}}], Axes -> True, 
   Boxed -> False, ColorOutput -> Blue](*vector b*);
s = Graphics3D[Arrow[{{2, 2, 5}, {3, -3, -6}}], Axes -> True, 
   Boxed -> False, ColorOutput -> Black](*vector a-b*);
Show[m, n, o, r, s]
$\endgroup$
2
  • 2
    $\begingroup$ Did you check the documentation for ColorOutput? It says that ColorOutput is only used in version 5 and below, what version of Mathematica are you using? Have you checked the documentation for Graphics3D? Can you find any examples that color objects? $\endgroup$ – C. E. Jan 23 '15 at 7:48
  • $\begingroup$ The Mathematica version is indeed needed. Why are you using Axes3D? What is it? $\endgroup$ – Öskå Jan 23 '15 at 15:21
2
$\begingroup$

You haven't defined Axes3D[]. Nevertheless:

n = ListPointPlot3D[{{4, 5, 6}, {3, -3, -6}, {2, 2, 5}}, 
   PlotLegends -> Automatic, ImageSize -> 400, 
   PlotStyle -> PointSize[0.03], PlotRange -> {-10, 10}];
o = Graphics3D[{Red, Arrow[{{4, 5, 6}, {3, -3, -6}}]}, Axes -> True, 
   Boxed -> False];
r = Graphics3D[{Blue, Arrow[{{4, 5, 6}, {2, 2, 5}}]}, Axes -> True, 
   Boxed -> False];
s = Graphics3D[{Black, Arrow[{{2, 2, 5}, {3, -3, -6}}]}, Axes -> True,
   Boxed -> False];
Show[n, o, r, s]

enter image description here

Or... more simply:

Graphics3D[{
  {PointSize[0.03], Point[{{4, 5, 6}, {3, -3, -6}, {2, 2, 5}}]},
  {Red, Arrow[{{4, 5, 6}, {3, -3, -6}}]},
  {Blue, Arrow[{{4, 5, 6}, {2, 2, 5}}]},
  {Black, Arrow[{{2, 2, 5}, {3, -3, -6}}]}},
 Axes -> True,
 PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]

enter image description here

Or tighter code, with internal axes:

Graphics3D[{
  {PointSize[0.03], Point[{{4, 5, 6}, {3, -3, -6}, {2, 2, 5}}]},
  MapThread[{#1, Arrow[#2]} &, 
{{Red, Blue, Black}, 
{{{4, 5, 6}, {3, -3, -6}}, {{4, 5, 6}, {2, 2, 5}}, {{2, 2, 5}, {3, -3, -6}}}}]},
 Axes -> True,
 AxesOrigin -> {0, 0, 0},
 PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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