There are hundreds of different anthocyanins, with over 600 to 700 identified, varying by sugar attachments and modifications, but they are all derived from about 17 core anthocyanidin structures, with just six (cyanidin, delphinidin, pelargonidin, peonidin, petunidin, malvidin) making up most of the common pigments.
Pelargonidin Orange-red or brick red
Cyanidin Magenta, crimson, or reddish-purple
Peonidin Magenta or purplish-red
Delphinidin Blue-reddish, purple, or blue-violet
Petunidin Dark-red or purple
Malvidin Bluish-purple or blue-red
The type of anthocyanin produced by a plant is fundamentally determined by its genetics. However, the environment can significantly influence the amount of anthocyanin produced and can affect factors like pH that subtly change the resulting color (hue). Combined with senescence, you can get some sensational rainbow colours.