Graphics Mathematica中使用图形3D的线样式
考虑以下几点:Graphics Mathematica中使用图形3D的线样式,graphics,3d,wolfram-mathematica,mathematica-8,Graphics,3d,Wolfram Mathematica,Mathematica 8,考虑以下几点: cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0,0}, {1, 0, 0}}}; Graphics3D[{Line /@ cAxes}, Boxed -> False] 这三行的风格如何不同?未经测试(我目前无法访问Mathematica): 下面是一个例子: 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[{Line /@ cAxes}, Boxed -> False]
这三行的风格如何不同?未经测试(我目前无法访问Mathematica):
下面是一个例子:
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]
上面的答案很好,但我想展示一些替代方案 我展示了可以使用
样式
实现这一点,并且管
是行
的有趣替代品
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]
我正在努力决定这是否是一个好答案。我不清楚500是想设计轴的样式,还是仅仅选择这些线条作为例子。@Mr.我不知道这是否是一个好的答案。我把它看作是另一种可能性的提醒。好吧,我喜欢这种可能性+1 ;-)我可以给你发一些我正在准备的小演示吗?我正在努力与一些图形,但代码是太长了@是的,说吧。我今天应该可以花点时间在上面。+1表示中缀符号~MapThread~,这使它“看起来”更像它的工作方式。@Daniel,谢谢。我喜欢使用中缀符号很多。它的显著优点是让我快速知道函数正处理两个参数,就像
@
或/
指示单个参数一样。实际上,我会将上面的Style函数编写为Tube@#~Style~#2&
,但我担心其他不熟悉中缀的人会感到困惑。由于这不是我第一次收到关于中缀的正面评论,所以我将不再担心,而是自由地使用它。celtschk,祝贺您从今天起成为本月的第一位新用户@巫师先生:谢谢你通知我这件事。同时也感谢你修复了我代码中的错误。
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]