Some cannabis strains are purple because of a higher concentration of anthocyanins. Anthocyanins are composed of a group of compounds that represent a basic structure below where each “R” is replaced by a hydrogen atom or chemical functional group.
Depending on the pH these compounds typically have a purple color in neutral conditions, a blue color in more alkaline conditions, and a red color in acid conditions. The color is affected by pH because a certain percentage of the compound will undergo a conformational change in three dimensional shape at specific protonation levels. This conformation change will absorb a different energy level of light that corresponds to a diferent wavelength of light. There can be different variations of anthocyanins in a plant, which lead to different light absorbing variations and the average of all of these compounds absorbing light are what contribute to the plants overall color along with the amount of chlorophyll in the plant. You may remember a science demonstration using red cabbage as pH indicator. This is essentially the same concept. It would be interesting to see if you could use a purple strain of cannabis that is genetically anthocyanin heavy to use as a pH indicator.
All cannabis contains anthocyanins. However, typically the amount is so low that the green chlorophyll overwhelms the color profile. Depending on the genetics of the cannabis plant, anthocyanins may be expressed in the later part of flowering and have varying degrees of intensity. From a botanical point, it has been postulated that the purpose of anthocyanins is to protect photosynthetic plant tissue from damage brought on by high light intensities at certain wavelengths. This paper by Zhou et al. has shown that light intensity and wavelength plays a role in anthocyanin production in cranberries. Another paper published by Xu et al. suggests that biosynthetic enzymes responsible for anthocyanin production in strawberries are still active when exposed to blue light after the fruit has been harvested. The abstract of the paper shows a photo of the noticeable different between the control group and the group exposed to blue light for 8 days. It can be reasonable to predict that light intensity and wavelength play a role in anthocyanin production in cannabis along with a specific strain’s genotype.