A flower in nature might use the same pigments to both color itself and as a stress response to oxidative damage.
Cannabis hasnt made any effort to evolve the simple leaf that makes the calyx into much of a flower and dosent seem too intrested in producing pretty coloured flowers prefering to let wind do that job of insects.
Since the plant can already produce that compound and through evolution and stress develop better responses we do see purple flowers on a green plant. What i disagree to is when the leaves and stems are blurple red all over and people attribute it to genetics and the evolution i just mentioned, at that point its stress and not simple flowers.
Forget canna, red lettuce is less efficient than green but in highlight do better than its green strain because its absorbing less light energy and not so stressed so grows better.
Anthocyanin is diverse, ive seen little study on other compounds either mixing or producing the same purple red pink violet colors in canna.
Its not easy to say, look at trichomes in other plants, reduce transpiration, triggered more by drought, protect against insects, not plesant to digest. We dont really have a one size fits all answer just a lot of answers and observations.
Its a cool plant, its evolved more than most, eager to spread the world over and solve problems. Survival of the fittest means once you learnt a helpfull trick you stick it in your arsenal. Plants like humans are at war with each other over resources and space, i only see canna as an apex predator.
I've always been thinking it's simply the cold causing that. The plant doesn't produce anything but it's simply the exposure to prolonged coldness that changes something in the plant's tissue.
I also think you that the purpling of stems or buds are two distinct separate phenomenae which have 0 to do with one another, and causedfor different reasons.