Anthocyanins have this basic chemical structure
Anthocyanins give these pansies their dark purple pigment
Anthocyanin is a chemical compound which makes the red colour in plants. For example, red cabbage has anthocyanins which make it red.
Showing maldavin (an anthocyanin) absorbs in a different range to chlorophyll
In flowers, bright-reds and purples attract pollinators. In fruits, the colourful skins also attract the attention of animals, which may eat the fruits and disperse the seeds.
In photosynthetic tissues (such as leaves and sometimes stems), anthocyanins have been shown to act as a "sunscreen". They protect cells from high-light damage by absorbing blue-green and ultraviolet light. Ionizing radiation can damage DNA.
There are some other suggestions. The red colour of leaves may camouflage leaves from herbivores blind to red wavelengths. The pigment may signal bad taste, since anthocyanin synthesis often comes with unpalatable phenolic compounds.
Making these pigments is done by a series of enzymes that are stuck on cell membranes.
Images for kids
Purple cauliflower contains anthocyanins.
Anthocyanins give these pansies their dark purple pigmentation
Reds and purples of autumn leaves of the European bilberry result from production of anthocyanins.
Red cabbage extract at low pH (left) to high pH (right)
Conventional breeding was used to produce P20 blue tomatoes