简体   繁体   中英

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]

在此输入图像描述

How can Style differently the 3 lines ?

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]

在此输入图像描述

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]

在此输入图像描述

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]

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]

未经测试(我现在无法访问Mathematica):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM