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.

I have these two lists

xyz={{1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1}, {-1, 1, 1}, {-1, 
  1, -1}, {-1, -1, 1}, {-1, -1, -1}}

color={GrayLevel[0.5], GrayLevel[0.5], RGBColor[0, 1, 0], GrayLevel[0.5], 
 GrayLevel[0.5], GrayLevel[0.5], GrayLevel[0.5], RGBColor[0, 1, 0]}

I need to use this function Graphics3D[{*Green*, Sphere[]}] to plot each sphere with coordinates from xyz list and colour from col list.

by applying MapThread[].

share|improve this question
    
Graphics3D[{dfhgkjdfhg, MapThread[{#1, Sphere[#2]} &, {col, xyz}]}] –  Emamof Jun 28 '12 at 21:59
    
Just an added detail: the colors will look more natural if you add Lighting -> "Neutral" at the end of Graphics (since I assume the true colors are important to you). –  Jens Jun 29 '12 at 16:07
add comment

2 Answers

You can do the following:

Graphics3D[MapThread[{#1, Sphere@#2} &, {color, xyz}]]

enter image description here

share|improve this answer
1  
Of course, if you want to avoid the hassle of MapThread[]: {color, Sphere /@ xyz} // Transpose // Graphics3D –  J. M. Jun 29 '12 at 0:56
    
Got it, Thanks for care. –  Emamof Jun 29 '12 at 3:53
add comment

Instead of MapThread you could use Map (/@) and Thread.

Graphics3D @ Thread @ {color, Sphere /@ xyz}

Or Map and Riffle:

Graphics3D @ Riffle[color, Sphere /@ xyz]

Mathematica graphics

share|improve this answer
    
Why the down-vote? –  Mr.Wizard Jun 29 '12 at 13:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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