1
$\begingroup$

I have a 3D plot of 8 adjoining cubes--each of which I've color-customized with CYMKColor.

I'd like to be able to install a monochromatic gradient from white-to-black by z coordinates, but I'm having a bit of trouble as I can only seem to blacken the color with CYMKColor and not whiten it

Here's my code and the graphic I have so far:

min = -10

med = 0

max = 10

arc = Graphics3D[{CMYKColor[1, 1, 0, 0, 0.7], 
   Cuboid[{min, med, med}, {med, max, max}]}]

arp = Graphics3D[{CMYKColor[1, 1, 0, 0, 0.7], 
   Cuboid[{med, med, med}, {max, max, max}]}]

alc = Graphics3D[{CMYKColor[0, 1, 1, 0, 0.7], 
   Cuboid[{min, min, med}, {med, med, max}]}]

alp = Graphics3D[{CMYKColor[0, 1, 1, 0, 0.7], 
   Cuboid[{med, min, med}, {max, med, max}]}]

llc = Graphics3D[{CMYKColor[1, 0, 1, 0, 0.7], 
   Cuboid[{min, min, min}, {med, med, med}]}]

llp = Graphics3D[{CMYKColor[1, 0, 1, 0, 0.7], 
   Cuboid[{med, min, min}, {max, med, med}]}]

lrc = Graphics3D[{CMYKColor[0, 0, 1, 0, 0.7], 
   Cuboid[{min, med, min}, {med, max, med}]}]

lrp = Graphics3D[{CMYKColor[0, 0, 1, 0, 0.7], 
   Cuboid[{med, med, min}, {max, max, med}]}]

Show[arp, arc, alp, alc, llp, llc, lrp, lrc]

Current Graphic

$\endgroup$
2
  • $\begingroup$ does RegionPlot3D[Cuboid[{med, med, min}, {max, max, med}], ColorFunction -> (Blend[{Append[.7]@White, CMYKColor[0, 1, 1, Rescale[#3, {min, max}], .7]}, Rescale[#3, {min, max}]] &), ColorFunctionScaling -> False] give something close to what you have in mind? $\endgroup$
    – kglr
    Commented Mar 5, 2021 at 0:20
  • $\begingroup$ @kglr Yes, that's the whiteness level I want the colors to approach as z approaches 10. Similarly, I want a blackness level that it approaches as z approaches -10. Do you know how I might do that? $\endgroup$ Commented Mar 5, 2021 at 0:25

1 Answer 1

3
$\begingroup$
RegionPlot3D[-10 <= x <= 10 && -10 <= y <= 10 && -10 <= z <= 
   10, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, Mesh -> 1, 
 ColorFunction -> Function[{x, y, z}, Blend[{White, Black}, z]], 
 Lighting -> {{"Ambient", White}}, Boxed -> False, Axes -> False, 
 MeshStyle -> Yellow, BoundaryStyle -> Green]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ This is enough for me to take it from here, thanks so much! $\endgroup$ Commented Mar 5, 2021 at 0:30

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.