0
$\begingroup$

How do I fill a 3D shape transparently. I know various ways to color the edges of the 3D shape transparently but this does not produce the result I want when looking from within the shape for example. A simple example to illustrate the problem can be seen in:

Show[RegionPlot3D[True, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, Mesh -> None,
   PlotStyle -> Directive[Green, Opacity[0.1]]], 
 PlotRange -> {{0., 0.5}, {0, 2}, {0, 2}}]

Here we see that the bottom appears a different color just because we are already looking from within the shape. What I would like is for the interior itself to be filled with color? Is this possible?

Example


Attempting the solution provided by @kglr works but ends up looking strange when combined with something else (and it gets even stranger looking as you rotate the plot. This is actually the best looking angle. The filling does not seem to render well.)

enter image description here

$\endgroup$
5
  • 2
    $\begingroup$ does Show[RegionPlot3D[True, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, BoundaryStyle -> Gray, Mesh -> None, PlotStyle -> None], DensityPlot3D[1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, OpacityFunction -> (.05 &), ColorFunction -> (Green &)], PlotRange -> {{0., 0.5}, {0, 2}, {0, 2}}] give something close to what you need? $\endgroup$
    – kglr
    Feb 1 '20 at 15:58
  • $\begingroup$ @kglr, thanks! I guess that is what I asked for but perhaps not what I actually wanted. I would prefer it if the "strange" square in the example figure would simply look more like the others. I figured that an opaque filling of the shape instead of its boundary would do that but of course it looks quite different at the edges as there is less to see through. I should have predicted that. (Also there seems to be a bug when I combine the density plot with another figure. It ends up looking strange consisting out of many planes rather than something dense.) $\endgroup$
    – Kvothe
    Feb 4 '20 at 15:26
  • $\begingroup$ Kvothe, then Vitaliy's (deleted) answer gets you what you need? $\endgroup$
    – kglr
    Feb 4 '20 at 19:23
  • $\begingroup$ @kglr, uhm how do I see that answer? I can't find it. $\endgroup$
    – Kvothe
    Feb 5 '20 at 11:40
  • $\begingroup$ Kvothe, @VitaliyKaurov's deleted post suggests using reg=ImplicitRegion[0<=x<=1&&0<=y<=1&&0<=z<=1,{x,y,z}]; RegionPlot3D[reg, PlotStyle->Directive[Green,Opacity[0.5]], PlotRange->{{0.,2},{0,2},{0,2}}]. $\endgroup$
    – kglr
    Feb 5 '20 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.