Reputation: 294
Can someone tell me how I can generate a contrasting color palette in python. I need a set of colors that give a good contrast (distinguished easily) on a plot in color and B/W. It is important to have contrast in B/W if not completely in color.
Thanks
edit: I am currently using matplotlib, python 2.7. I use the default pyplot which generates colors which can sometimes be very close specially when converted to B/W. I would like to generate colors that can be distinguished easily even in shades of grey. I am not using any additional libraries.
Upvotes: 1
Views: 9940
Reputation: 52337
In plotting what you describe as a color palette is referred to as colormap.
There are several sequential colormaps that fulfill the desired properties. I suggest you have a look at the colormaps provided by matplotlib (examples) for starters, but I agree it is hard to find ones with perceptually linear luminance that really add something to just B/W.
If you like to devulge further into the topic of finding the 'perfect' colormap, I suggest you have a look at the works by Kenneth Moreland and Peter Kovesi. They both provide links for using/generating their colormaps in python.
I find the colormaps by Kenneth Moreland to be especially intriguing for perceptually linear luminance or linearly increasing brightness.
Upvotes: 2