Skip to main content

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

(1) One of a subset of colors, e.g. {Green, Red}

(2) A random color over some RGB interval

  1. One of a subset of colors, e.g. {Green, Red}
  2. A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]], Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

...appears to only assign one random color to all of the spheres. 

I can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simpler way to make this work?is there a simpler way to make this work?

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

(1) One of a subset of colors, e.g. {Green, Red}

(2) A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]],Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

...appears to only assign one random color to all of the spheres. I can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simpler way to make this work?

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

  1. One of a subset of colors, e.g. {Green, Red}
  2. A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]], Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

...appears to only assign one random color to all of the spheres. 

I can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simpler way to make this work?

How can I randomly Randomly assigning color to Graphics3D objects?

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

(1) One of a subset of colors, e.g. {Green, Red}

(2) A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]],Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

Appears...appears to only assign one random color to all of the spheres. II can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simplesimpler way to make this work?

How can I randomly color Graphics3D objects?

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

(1) One of a subset of colors, e.g. {Green, Red}

(2) A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]],Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

Appears to only assign one random color to all of the spheres. I can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simple way to make this work?

Randomly assigning color to Graphics3D objects?

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

(1) One of a subset of colors, e.g. {Green, Red}

(2) A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]],Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

...appears to only assign one random color to all of the spheres. I can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simpler way to make this work?

Source Link
Roger Harris
  • 1.5k
  • 1
  • 13
  • 20

How can I randomly color Graphics3D objects?

I have a set of Graphics3D primitives (here, spheres) which I would like to assign either:

(1) One of a subset of colors, e.g. {Green, Red}

(2) A random color over some RGB interval

Writing something like:

Graphics3D[{RGBColor[RandomInteger[{0, 1}], RandomInteger[{0, 1}], RandomInteger[{0, 1}]],Sphere[{#[[1]], #[[2]], #[[3]]}, #[[4]]] & /@ SphereList... 

Appears to only assign one random color to all of the spheres. I can force this to work by generating a string that explicitly specifies a random color for each sphere, but is there a simple way to make this work?