考虑以下 :
cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0,0}, {1, 0, 0}}};
Graphics3D[{Line /@ cAxes}, Boxed -> False]
如何对 3 行进行不同的样式设置?
考虑以下 :
cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0,0}, {1, 0, 0}}};
Graphics3D[{Line /@ cAxes}, Boxed -> False]
如何对 3 行进行不同的样式设置?
上面的答案很好,但我想展示一些替代方案。
我展示了它可以Style
用于这个,这Tube
是一个有趣的替代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]
这是一个例子:
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]
还要记住,如果需要,您可以对 Plot3D 执行相同的操作:
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]
你也可以使用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]