【问题标题】:Sphere Styling and Grid Spacing in Graphics3DGraphics3D 中的球体样式和网格间距
【发布时间】:2011-11-14 00:02:33
【问题描述】:

请考虑:

colors = {Red, Green, Blue};
style = {Thickness[.01], Thickness[.01], Thickness[.01]};
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}, 
Blue, Specularity[White, 3], Sphere[{.5, .5, .5}, .1]}, 
Boxed -> False, FaceGrids -> All, 
FaceGridsStyle -> Directive[Black, Dashed]]

在How to Style Lines上使用尤达的解决方案

我如何使用 GrayLevel 为球体着色(稍后我将对其进行操作)。

我怎样才能拥有更密集的 FaceGrids ?水平和垂直 10 行。我也不明白为什么 Edges 之间的距离很远。

【问题讨论】:

    标签: wolfram-mathematica graphics3d


    【解决方案1】:

    最好将图形对象及其样式分组到一个列表中,以防您需要快速添加另一个具有不同样式的对象。我的意思是把它写成{Blue, Specularity[White, 3], Sphere[{.5, .5, .5}, .1]}。现在您可以轻松地在Sphere 之前添加一个GrayLevel 术语,它会起作用。

    对于FaceGrids,我相信您必须手动定义每个面所需间距的线条。这是一个示例,用于展示如何为一张脸执行此操作。

    Graphics3D[{{#1, #2, Line@#3} & @@@ 
       Transpose@{colors, style, cAxes}, {Blue, GrayLevel[0.3], Lighting -> "Neutral",
       Specularity[White, 3], Sphere[{.5, .5, .5}, .1]}}, Boxed -> False, 
     FaceGrids -> {{{0, 0, 1}, 
        Transpose@({#, #} & /@ Range[0, 1, 0.1])}}, 
     FaceGridsStyle -> Directive[Black, Dashed]]
    

    对应平面的面定义为±1,其他两个为零。所以{0,0,1}在我的例子中对应于z=1平面。

    提供给FaceGrids 的列表可以很容易地为每个人脸计算,而不是手动输入它们,但我会把它留给你 :)

    编辑:

    因为你想要一个统一的网格,所以定义你想要绘制网格线的位置

    gridList = Transpose@({#, #} & /@ Range[0, 1, 0.1]);
    

    然后,将以下内容用于FaceGrids:

    FaceGrids -> Join @@ Table[{RotateLeft[j {0, 0, 1}, i], gridList}, 
        {i, {0, 1, 2}}, {j, {-1, 1}}]
    

    PlotRangePadding -> None 的结果如下所示:

    【讨论】:

    • 这次你打败了我:-)
    • 谢谢,但是我希望这个球体基本上是黑白的。有可能吗?
    • 啊照明 -> 中性,是吗!
    • @Yoda,我做错了什么:-)? : FaceGrids -> {{#, Transpose@({#, #} & /@ Range[0, 1, 0.1])}} & /@ {{0, 0, 1}, {0, 0, -1} }
    • @Yoda, FaceGrids -> 函数[ou, {ou, Transpose@({#, #} & /@ Range[0, 1, 0.1])}] /@ {{0, 0 , 1}, {0, 0, -1}} 。这是我唯一能做的 :-( 除了 0 或 -1 之外,它没有任何其他值 :-(
    【解决方案2】:

    除了尤达的回应:

    • Lighting -> "Neutral" 将允许灰度对象显示为灰色而不是各种颜色。

    • PlotRangePadding -> None 将删除网格线上的空格(取决于PlotRange 的设置。)

    【讨论】:

      【解决方案3】:

      Yoda 击败我输入了FaceGrids 设置(请参阅documentation)。但这里有一个替代方案。

      除了显式设置FaceGrids,您还可以尝试设置FrameTicks,因为默认情况下FaceGrids遵循这些设置,然后使用Opacity将FrameTicks设置为不可见。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-12
        • 2011-12-26
        相关资源
        最近更新 更多