简体   繁体   English

Graphics3D中的球体样式和网格间距

[英]Sphere Styling and Grid Spacing in Graphics3D

Please consider : 请考虑 :

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]]

Using Yoda`s solution on How to Style Lines 使用Yoda的解决方案如何设计线条

How could I color the Sphere using GrayLevel (I will manipulate it later). 我怎样才能使用GrayLevel为球体着色 (稍后我将对其进行操作)。

And How could I have denser FaceGrids ? 我怎么能拥有更密集的FaceGrids 10 Lines horizontally & Vertically. 水平和垂直10条线。 I also don`t understand why the Edges one are distant to one another. 我也不明白为什么边缘彼此相距遥远。

在此输入图像描述

It's always good practice to group the graphics object and its styles in a list, in case you need to quickly add another one with different styles. 将图形对象及其样式分组在列表中总是很好的做法,以防您需要快速添加另一个具有不同样式的对象。 By that, I mean write it as {Blue, Specularity[White, 3], Sphere[{.5, .5, .5}, .1]} . 我的意思是把它写成{Blue, Specularity[White, 3], Sphere[{.5, .5, .5}, .1]} Now you can easily add a GrayLevel term before Sphere and it'll work. 现在,您可以在Sphere之前轻松添加GrayLevel术语,它将起作用。

For the FaceGrids , I believe you'll have to manually define the lines at your desired spacing for each face. 对于FaceGrids ,我相信你必须为每张脸以所需的间距手动定义线条。 Here's an example for showing how to do it for one face. 这是一个展示如何为一张脸做的例子。

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]]

在此输入图像描述

The faces are defined as ±1 for the corresponding plane and the other two are zero. 对于相应的平面,面定义为±1 ,另外两个面为零。 So {0,0,1} in my example corresponds to the z=1 plane. 所以我的例子中的{0,0,1}对应于z=1平面。

The list supplied to FaceGrids can be easily computed for each face, instead of manually entering them, but I'll leave that to you :) 提供给FaceGrids的列表可以很容易地为每个面部计算,而不是手动输入它们, 但我会留给你:)

EDIT: 编辑:

Since you want a uniform mesh all around, define where you want the grid lines drawn as 由于您需要四周均匀的网格,因此请定义绘制网格线的位置

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

Then, use the following for FaceGrids : 然后,对FaceGrids使用以下FaceGrids

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

Here's how the result should look like with PlotRangePadding -> None : 以下是PlotRangePadding -> None

在此输入图像描述

In addition to Yoda's response: 除了尤达的回应:

  • Lighting -> "Neutral" will allow grayscale object to show up as gray instead of with various colors. Lighting -> "Neutral"将允许灰度对象显示为灰色而不是各种颜色。

  • PlotRangePadding -> None will remove the spaces on the grid lines (depending on the setting for PlotRange .) PlotRangePadding -> None将删除网格线上的空格(取决于PlotRange的设置。)

Yoda beat me to typing out the FaceGrids setting (see documentation ). Yoda打败我打字FaceGrids设置(见文档 )。 But here is an alternative. 但这是另一种选择。

Instead of setting the FaceGrids setting explicitly, youcould also try setting FrameTicks , since by default the FaceGrids follow these, and then style the FrameTicks to be invisible using Opacity . 您可以尝试设置FrameTicks ,而不是显式设置FaceGrids设置,因为默认情况下FaceGrids遵循这些设置,然后使用OpacityFrameTicks设置为不可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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