There are approximately 170,000 species of butterflies and moths, so there has to be a foolproof way for members of the same species to recognize each other. The bright metallic blue morpho butterfly of the neotropics flies rapidly up and down river corridors trying to attract females to mate with. They can be fooled by flashing a bright blue card in the sunlight. Some color patterns in butterflies represent warning coloration. Butterflies such as the monarch sequester cardiac glycosides from plants that are distasteful to predators.
Birds can learn to avoid certain color patterns.
Some butterflies that are perfectly edible, such as the viceroy butterfly, have color patterns that mimic the monarch butterfly. As a result, predators tend to avoid these mimics as well as the models. This type of mimicry is called Batesian mimicry. Many species of butterflies have different color patterns on the topside and the underside of the wings. The topside may be brightly colored, but the color pattern of the underside of the wings which are visible when the wings are closed often blends very well with the surrounding environment.