1
$\begingroup$

I want to plot a 3D coordinates list while specifying each plot point a specific color taken from a color list.

Example:

XYZColorList = {{0.173534, 0.0893428, 0.0142678}, {0.470538, 0.355548,
 0.295788}, {0.475933, 0.360228, 0.300325}, {0.610688, 0.493085, 
0.443235}, {0.318969, 0.228664, 0.183534}, {0.315712, 0.227049, 
0.180459}, {0.0568048, 0.0291903, 0.00716188}, {0.0312732, 
0.0160486, 0.00492864}, {0.202566, 0.135997, 0.101508}, {0.205762,
 0.138551, 0.10393}};
XYZColors = Map[XYZColor, XYZColorList];
MunsellCoords = {{2.6711, -13.8497, 3.52451}, {-1.08771, -9.162, 
    6.51566}, {-1.09224, -9.1496, 6.55217}, {-0.973016, -7.894, 
    7.48612}, {-1.14851, -9.10948, 5.38254}, {-1.01615, -9.02445, 
    5.36571}, {2.87426, -9.10554, 1.95285}, {2.63322, -6.94949, 
    1.27857}, {-0.944056, -8.76566, 4.27216}, {-0.959735, -8.76519, 
    4.30807}};
ListPointPlot3D[MunsellCoords, PlotStyle -> PointSize[0.033]]

So far, I've tried several examples on StackExchange where such questions are asked but I cannot figure it.

I tried a list of Directives for PlotStyle and a list of Style for the data yet.

I'm probably missing something simple. Any help would be appreciated.

Using Mathematica 11.2 on Windows

$\endgroup$

2 Answers 2

3
$\begingroup$

Another way:

ListPointPlot3D[MunsellCoords, PlotStyle -> PointSize[0.033]] /. 
 Point[x_] :> Point[x, VertexColors -> XYZColors]

enter image description here

$\endgroup$
1
  • $\begingroup$ This method solved my issue. I still don't understand why I was getting errors (see comments in previous answer) using @kglr method though. Especially given that I've been using this method in previous plots without issues. So I'm obviously doing a little thing wrong and I just can't spot it. $\endgroup$ Dec 9, 2019 at 5:12
4
$\begingroup$
ListPointPlot3D[MapThread[Style, {MunsellCoords, XYZColors}], 
 PlotStyle -> PointSize[0.033]]

enter image description here

Alternatively,

ListPointPlot3D[Thread[Style[MunsellCoords, XYZColors]], 
 PlotStyle -> PointSize[0.033]]

same picture

ListPointPlot3D[List /@ MunsellCoords, 
 PlotStyle -> XYZColors, 
 BaseStyle -> PointSize[0.033]]

same picture

or

ListPointPlot3D[List /@ MunsellCoords, 
 PlotStyle -> Thread[Directive[XYZColors, PointSize[0.033]]]]

same picture

$\endgroup$
4
  • $\begingroup$ I don't understand what I'm doing wrong. I copied your example verbatim but I get the following errors: MapAt::partw: Part {10} of {{Directive[,PointSize[0.033]],Point[{{2.6711,-13.8497,3.52451},{-1.08771,-9.162,6.51566},{-1.09224,-9.1496,6.55217},{-0.973016,-7.894,7.48612},{-1.14851,-9.10948,5.38254},{-1.01615,-9.02445,5.36571},{2.87426,-9.10554,1.95285},{2.63322,-6.94949,1.27857},{-0.944056,-8.76566,4.27216},{-0.959735,-8.76519,4.30807}}]}} does not exist. MapAt::partw: Part {9} of MapAt[#1&,{{Directive[,PointSize[0.033]],Point[{{2.6711,-13.8497,3.52451},{,,,etc. $\endgroup$ Dec 9, 2019 at 4:16
  • $\begingroup$ Seems I can't edit the comment after 5 minutes. The XYZColor square did not copied in my comment, So read "Directive[<color square>,PointSize[..." $\endgroup$ Dec 9, 2019 at 4:27
  • $\begingroup$ I also get this error in the console: "MapAt is not a Graphics3D primitive or directive." $\endgroup$ Dec 9, 2019 at 4:30
  • $\begingroup$ @YvesPoissant, it could be a version/os problem (the posted methods work without error in ver 11.3 (windows 10) for your posted lists XYZColors and MunsellCoords). In general, the methods should work for lists XYZColors and MunsellCoords that have the same length. $\endgroup$
    – kglr
    Dec 9, 2019 at 15:33

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.