500
500

Reputation: 6619

Line Style using Graphics3D in Mathematica

Consider the following :

cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0,0}, {1, 0, 0}}};

Graphics3D[{Line /@ cAxes}, Boxed -> False]

enter image description here

How can Style differently the 3 lines ?

Upvotes: 3

Views: 720

Answers (5)

Mr.Wizard
Mr.Wizard

Reputation: 24336

The answer above are good, but I want to show some alternatives.

I show that it is possible to use Style for this, and that Tube is an interesting alternative to Line.

cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 
     0}, {1, 0, 0}}};

tubes = Tube@# ~Style~ #2 & ~MapThread~ {cAxes, {Red, Green, Blue}};

Graphics3D[tubes, Boxed -> False]

enter image description here

Upvotes: 6

Dr. belisarius
Dr. belisarius

Reputation: 61026

Also remember that you can do the same with Plot3D if you need it:

colors = {Red, Green, Blue};
style = {Dashed, DotDashed, Dotted};
Plot3D[{}, {x, 0, 10}, {y, 0, 10}, 
 AxesLabel -> {x, y, z}, 
 AxesStyle -> Directive /@ Transpose@{colors, style}, 
 Boxed     -> False]

Upvotes: 4

Brett Champion
Brett Champion

Reputation: 8577

You could also use MapThread:

cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 0}, {1, 0, 0}}};

Graphics3D[{
   MapThread[{#1, Line[#2]} &, {{Red, Blue, Green}, cAxes}]
   }, Boxed -> False]

Upvotes: 4

celtschk
celtschk

Reputation: 19721

Untested (I don't have access to Mathematica right now):

Graphics3D[Transpose@{{Red, Green, Blue}, Line /@ cAxes}, Boxed -> False]

Upvotes: 3

abcd
abcd

Reputation: 42225

Here's an example:

colors = {Red, Green, Blue};
style = {Dashed, DotDashed, Dotted};
cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 
     0}, {1, 0, 0}}};
Graphics3D[{#1, #2, Line@#3} & @@@ Transpose@{colors, style, cAxes}, 
 Boxed -> False]

enter image description here

Upvotes: 4

Related Questions