# Color coding points on spherical plot

I have a matrix with each element having two components. First component is an array of six elements, each of multiple of 1/6 but less than 1. Second component has two elements representing spherical coordinates (phi, theta). Following matrix shows an example with four elements.

{{{2/3, 0, 1/6, 0, 0, 1/6}, 0, 0}, {{1/3, 1/3, 1/6, 0, 0, 1/6},
0, Pi/56}, {{2/3, 0, 1/6, 0, 0, 1/6}, 0, Pi/28}, {{2/3, 0, 1/6, 0, 0, 1/6}, 0, (3 Pi)/56}


Here, first element has the spherical coordinates (0, 0) with six elements being {2/3, 0, 1/6, 0, 0, 1/6} and so on. I want to plot this matrix in spherical coordinate system such that each point is colored according to the first element of the six element array...say red for 2/3, green for 1/3 blue for 1/6 etc. So {2/3, 0, 1/6, 0, 0, 1/6}, 0, 0} should mean a red color dot at sphere at spherical coordinates (0, 0).

Will appreciate any help. thanks

• What are you trying to plot... spherical coordinates require 3 coordinates, but you've only supplied two and it's not clear what the first element of each list should do. – b3m2a1 Jun 26 '19 at 7:07

Since you have a constant coordinate we can just plot this in 2D I figure:

transf = Evaluate[CoordinateTransform["Polar" -> "Cartesian", {#, #3}]] &;

points = {
{{2/3, 0, 1/6, 0, 0, 1/6}, 0, 0}, {{1/3, 1/3, 1/6, 0, 0, 1/6}, 0,
Pi/56}, {{2/3, 0, 1/6, 0, 0, 1/6}, 0, Pi/28}, {{2/3, 0, 1/6, 0, 0, 1/6},
0, (3 Pi)/56}
};

Map[{ColorData[98][6*#[[1]]], Point[transf @@ #]} &, Thread[#]] & /@ points //
Graphics[{PointSize -> Large, #}] &


Alternately if you really want it in 3D:

transf = Evaluate[
CoordinateTransform["Spherical" -> "Cartesian", {#, #3, #2}]] &;

Map[{ColorData[98][6*#[[1]]], Point[transf @@ #]} &, Thread[#]] & /@ points //
Graphics3D[{PointSize -> Large, #},
PlotRange -> {{-.2, .2}, {-.1, .1}, All}] &


Do you mean something like this?

a = {{{2/3, 0, 1/6, 0, 0, 1/6}, 0, 0}, {{1/3, 1/3, 1/6, 0, 0, 1/6}, 0,
Pi/56}, {{2/3, 0, 1/6, 0, 0, 1/6}, 0,
Pi/28}, {{2/3, 0, 1/6, 0, 0, 1/6}, 0, (3 Pi)/56}};

R = 1;
Graphics3D[{
Table[{Hue@a[[i, 1, 1]], PointSize[0.025], Point[R*{
Sin[a[[i, 3]]] Cos[a[[i, 2]]],
Sin[a[[i, 3]]] Sin[a[[i, 2]]],
Cos[a[[i, 3]]]
}
]}, {i, 1, Length@a}]}, BoxRatios -> {1, 1, 1}
]


• Thanks. something similar but on spherical surface. – user49535 Jun 26 '19 at 6:38
• As you see, I've used the Graphics3D for drawing. Therefore, you can add there any spheres or cuboids as you wish ) – Rom38 Jun 26 '19 at 7:26