I'm using ParametricPlot3D to show only the mesh points, but would like to vary their opacity by reference to a function of their original position.

  Table[{X + Y, Y + Z, X + Z}, {X, -3, 3}, {Y, -3, 3}], {Z, -3, 3}, 
  Axes -> False, Mesh -> All, PlotStyle -> None, 
  MeshStyle -> Directive[PointSize[Small], Opacity[Abs[X]/7]], 
  PlotPoints -> 7, MaxRecursion -> 0]

Clearly not working. Help gratefully received, I am very new to Mathematica.

  • $\begingroup$ The variable X only exists in Table. It is not known to ParametricPlot3D. $\endgroup$ – m_goldberg Mar 27 '16 at 0:28
  • 3
    $\begingroup$ Why don't use directly Graphics and Point to draw the collection of points? $\endgroup$ – unlikely Mar 27 '16 at 0:37

I don't know to make what you want work with ParametricPlot3D, but it's not too hard with plain, old Graphics3D. Here is one way it can be done.

I use Table and Cases and Transpose to make a list containing two lists, the 1st being the source points and the 2nd being the image points.

data = 
  Transpose @
        {{x, y, z}, {x + y, y + z, x + z}}, 
        {x, -3, 3}, {y, -3, 3}, {z, -3, 3}],
      _, {-3}];

Then I render the points with varying opacity, taking the x-coordinate of each source point from the 1st of two lists in data and using it in opacity computation. The positions of the plotted image points are taken from the 2nd list.

    {Opacity[.1 + .3 Abs[#1[[1]]]], 
       Glow[RGBColor[1/10, 2/3, 1]], 
         Sphere[#2, Scaled[.005]]} &, 
  BoxRatios -> {1, 1, 1},
  Lighting -> None]



  • I used Sphere rather than Point to render the points because I think spheres look better in 3D graphics.
  • I turned lighting off and used Glow to color the spheres with a shade of blue that I favor.
  • I scaled the opacity to remain in the range 0 to 1. In the scaling expression #1[[1]]] designates the x-coordinate of the source points.
  • $\begingroup$ thanks, this worked a treat for me, and I learned a lot more applying it to my more complicated real life example ! $\endgroup$ – G Taylor Mar 28 '16 at 13:01

For the specific case, you can also solve for X and post-process the ParametricPlot3D output to change the opacities:

pp = ParametricPlot3D[
   Table[{X + Y, Y + Z, X + Z}, {X, -3, 3}, {Y, -3, 3}], {Z, -3, 3}, 
   Axes -> False, Mesh -> All, PlotStyle -> None, 
   MeshStyle -> Directive[PointSize[Large], Blue], PlotPoints -> 7, 
   MaxRecursion -> 0];
X /. Solve[{X + Y, Y + Z, X + Z} == {u, v, w}, {X, Y, Z}]

{ (u - v + w)/2}

Row[{pp, Normal[pp] /. 
   Point[x_] :> {Opacity[Abs[(1/2) (x[[1]] - x[[2]] + x[[3]])]/7], Point[x]}}]

Mathematica graphics

You can also use

foo = Abs[(# - #2 + #3)/2]/7 &;
Normal[pp] /. Point[x_] :> {Opacity[foo @@ x], Point[x]}

to get the same result.


Your Answer

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

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