问题
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 ?
回答1:
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]
回答2:
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]
回答3:
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]
回答4:
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]
回答5:
Untested (I don't have access to Mathematica right now):
Graphics3D[Transpose@{{Red, Green, Blue}, Line /@ cAxes}, Boxed -> False]
来源:https://stackoverflow.com/questions/8115641/line-style-using-graphics3d-in-mathematica