[thelist] How to Make a Set of Different Random Colors

Luther, Ron Ron.Luther at hp.com
Thu Aug 14 08:39:45 CDT 2008


Fred Jones noted:

>>I am making charts on the fly but all data is dynamic,
>>including the number of elements. How can I generate nice
>>colors so that each slice of the pie chart will be a different,
>>unique, yet BRIGHT color? I am using this now:

>>the last slice, which may be 13, maybe a bit more.


Hi Fred,

I see two approaches.  Let's start with the 'easy' one.  Let's say you need to chart a maximum of 15 different pie slices. (I'm pretty sure Tufte would say that's too many - but eh, whatcha gonna do?)  Go into your favorite color picking application and select your favorite 40-ish eyebleeding shades and load those into a small table indexed on some numeric id field.  Now mod your app to randomly select numbers from 1 to 40 and pull the color values out of this small table.  You will always get colors you like (or colors you evilly pre-selected specifically to give your CEO a migraine) and they will appear 'random' enough to keep your audience smiling.  Done.

>>Anyone who understands colors a bit more have any better suggestions?

I don't think you're talking to me here, but you could approach this the 'hard' way and build some application like Agave but get it to work on a random number of shades instead of a tetrad.  Selecting the initial random tetrad shouldn't be too tough.  But then I think you would need to spawn secondary tetrads [1] off the initial tetrad and then randomly restrict the result set to the number of slices you need.  Good luck with that route.  Sounds like it could be a fun little project, but it may take a while to get the results you want.


HTH,
RonL.

[1] (and possibly tertiary if you need enough pie slices - cut back on the pie, dude)



More information about the thelist mailing list