6
$\begingroup$

Here is a minimum example:

dots[x_, y_, z_] := {Green, EdgeForm[None], Sphere[{x, y, z}, 0.105], 
  Lighting -> "ThreePoint"}
With[{Aa = {0, 1, 0}, Bb = {1, 0, 0}}, 
 Graphics3D[Table[dots @@ (Aa j + Bb k), {j, 1, 20}, {k, 1, 20}], 
  Boxed -> False, PlotRange -> {{0, 15}, {1.38, 6.13}, {0, 1}}]]    

this gives the desired results as in the picture below

enter image description here

Now if I replace Green with MaterialShading["Plastic"] PlotRange is not working properly

dots[x_, y_, z_] := {MaterialShading["Plastic"], EdgeForm[None], 
  Sphere[{x, y, z}, 0.105], Lighting -> "ThreePoint"}
With[{Aa = {0, 1, 0}, Bb = {1, 0, 0}}, 
 Graphics3D[Table[dots @@ (Aa j + Bb k), {j, 1, 20}, {k, 1, 20}], 
  Boxed -> False, PlotRange -> {{0, 15}, {1.38, 6.13}, {0, 1}}]]   

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Looks like a bug to me. However, I am not sure that PlotRange is specifically to blame here. In fact, the buggy behavior is actually much more obvious if you turn the Box back on (Boxed -> True, i.e. the default behavior): this shows that, with MaterialShading, items are drawn outside the box specified by PlotRange. $\endgroup$
    – MarcoB
    Commented Oct 5, 2021 at 16:24

1 Answer 1

1
$\begingroup$
$Version
(*12.3.0 for Microsoft Windows (64-bit) (May 10, 2021)*)

Try this:

dots[x_, y_, z_] := {{MaterialShading["Plastic"]}, EdgeForm[None], 
    Sphere[{x, y, z}, 0.105], Lighting -> "ThreePoint"}
With[{Aa = {0, 1, 0}, Bb = {1, 0, 0}}, 
  Graphics3D[Table[dots @@ (Aa j + Bb k), {j, 1, 20}, {k, 1, 20}], 
    Boxed -> False, PlotRange -> {{0, 15}, {1.38, 6.13}, {0, 1}}]]
 

balls

The small change is as follows:

MaterialShading["Plastic"]->{MaterialShading["Plastic"]}

However, MaterialShading doesn't work properly with PlotRange.

Another way:

dots[x_, y_, z_] := Sphere[{x, y, z}, 0.105]
data = With[{Aa = {0, 1, 0}, Bb = {1, 0, 0}}, 
Table[dots @@ (Aa j + Bb k), {j, 1, 5}, {k, 1, 15}]];
Show[Map[Graphics3D[{MaterialShading["Plastic"], #}, 
Boxed -> False] &, data]]

balls2

$\endgroup$
3
  • 1
    $\begingroup$ Your code seems identical to the one in the OP. Can you point out the differences, and explain what the problem is and how you solved it? Could you also add your version of MMA and operating system? $\endgroup$
    – MarcoB
    Commented Oct 8, 2021 at 3:06
  • $\begingroup$ Apparently, MaterialShading doesn't work properly with PlotRange. $\endgroup$ Commented Oct 8, 2021 at 6:52
  • $\begingroup$ @E.Chan-López, I provide a minimal example, however, my data is more complicated and I need to impose PlotRange. By the way, is it possible to use DiscretizeRegion instead of PlotRange? $\endgroup$
    – MMA13
    Commented Oct 10, 2021 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.