# How may I vary the opacity of mesh points by reference to their original coordinates

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.

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[Small], Opacity[Abs[X]/7]],
PlotPoints -> 7, MaxRecursion -> 0]


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

• The variable X only exists in Table. It is not known to ParametricPlot3D. – m_goldberg Mar 27 '16 at 0:28
• Why don't use directly Graphics and Point to draw the collection of points? – 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 @
Cases[
Table[
{{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.

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

• 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[]] designates the x-coordinate of the source points.
• thanks, this worked a treat for me, and I learned a lot more applying it to my more complicated real life example ! – 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[] - x[] + x[])]/7], Point[x]}}] You can also use

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


to get the same result.