Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have a set of 2- or 3-space coordinates in an array, $(v_1,...,v_N)$, and an array of RGB color values (outputs from ImageValue[]) for each coordinate, $(c_1,...,c_N)$. How can I output a graphics3D image where I have, say, spheres at each coordinate $v_i$ with an associated color $c_i$?

For an example with two coordinates, I might have a coordinate array {{0,10,0}, {20,30,0}} and a color array {{0.529412, 0.529412, 0.529412}, {0.647059, 0.647059, 0.647059}}. I'd ideally like to be able to output two spheres are positions {{0,10,0}, {20,30,0}} in 3-space, where the first sphere has RGB value {0.529412, 0.529412, 0.529412} and the second sphere has RGB value {0.647059, 0.647059, 0.647059}.

share|improve this question

marked as duplicate by J. M. May 9 '13 at 1:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Well, you didn't initially specify how your colors were formatted. I've now written an answer. –  J. M. May 9 '13 at 0:49
    
@J.M. Very good, thank you! –  QuadraticU May 9 '13 at 0:50

1 Answer 1

Graphics3D[MapThread[{RGBColor @@ #1, Sphere[#2, 1]} &,
                     {{{0.529412, 0.529412, 0.529412}, {0.647059, 0.647059, 0.647059}},
                      {{0, 10, 0}, {20, 30, 0}}}], Lighting -> "Neutral"]

some gray spheres

But, if you can, why not stick to two dimensions?

Graphics[MapThread[{RGBColor @@ #1, Disk[Most[#2], 1]} &,
                   {{{0.529412, 0.529412, 0.529412}, {0.647059, 0.647059, 0.647059}},
                    {{0, 10, 0}, {20, 30, 0}}}]]

and some gray disks

share|improve this answer

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