Whenever you want to cross a street you must be sure that the traffic lights are not red. You rejoice also when you see that the sky is blue instead of grey and you avoid eating those fruits that are too green. From politics to fashion, from public signs to corporative brands, colors are everywhere. We are not the only ones that use them though, since many living beings can use or interpret color-based signals of many types. The ability to see colors is simply the result of some cell populations responding differentially to distinct regions of the electromagnetic spectrum.
Color vision has a long history in vertebrates. In most fishes, reptiles and birds it is possible to find four types of opsin receptor retinal cones, allowing them for the detection of four different wavelengths (tetrachromatic vision). Opsin receptors are G-protein coupled photoreceptors with seven transmembrane regions that detect light thanks to a retinal cofactor. The retinal cofactor is derived from carotene pigments, and has the property of shifting between a cis and trans state when excited by light. Despite sharing the same cofactor, different opsins can have different absorption spectra, and thus they respond to different wavelengths. Combining the signal of more than one type of opsin, animals are able to see colors.
The presence of the same four photoreceptors in lampreys implies that tetrachromatic vision evolved before jaws, meaning that this feat was probably present in ancient placoderms. Color vision has a great relevance in the ecophysiology of many animals, and it is known in teleost fishes that the wavelength optima of these photoreceptors vary as an adaptation to different environments. Mammals are, however, an exception to this rule as they have lost two of the opsin receptors, one before the split of monotremes (Platypus have three of the four families and trichromatic vision) and other before the split of marsupials and eutheria. Apparently, mammal ancestors during the Mesozoic were mostly nocturnal, and thus the gene loss we observe today can be poetically described as the result of a long stance at the shadow of dinosaurs.
Nearly all eutherian mammals have the ability to distinguish only two wavelengths (dichromatic vision). The only exception are several lineages that have lost one of the receptors, rendering their vision totally monochromatic possibly as a consequence of nocturnal habits; and primates. In old world primates, including anthropoid apes, a duplication in the medium wave sensitive opsin gene and subsequent divergence (In Homo sapiens, the gene is OPN1MW) has produced a new receptor with a new wavelength optimum, allowing a true trichromatic vision.
Both paralogs are located in the X chromosome, and they share a 98% of identity. Mutations in this duplicated gene causes deuteranopia, the most common form of partial colorblindness. This X-ligated visual alteration produce difficulties for the discrimination of red and green hues and is estimated to affect 8% of males and 0.5% of females in european populations. You can test your colorblindess phenotype here: http://www.color-blindness.com/2012/10/22/ishiharas-test-for-colour-deficiency38-plates-edition/. Of note two members of the current PhylomeDB team are affected by partial colorblindness, so do not be too harsh when judging the choice of colors in the web-design. As a final curiosity, colorblindness genes were the first to be mapped to a mammalian chromosome by Wilson in 1911.