Why so many fruits/veg fall into these color categories? Disclaimer: This question is not about cooking per se, rather about food itself; please let me know if this is not appropriate for this SE.
I have noticed that there are many fruits and vegetables which seem unrelated that come in two color varieties, red and yellowish-green. What I mean by this is that we have red onions and yellowish-green onions, we have red apples and yellowish-green apples. I will put a list of all such foods I have thought of; but I can't seem to find a reason why? Does this have to do with the chemistry, or the environmental conditions that cause different varieties to have different colors. I've tried looking online for this, but I cannot seem to formalize my question in a succinct and clear way to obtain results.
Here is a list of fruits and vegetables which have red varieties and yellowish-green varietes.

Apples
Onions
Raddish
Bell Peppers
Potatoes
Figs
Dragon Fruit (Yellow Dragon fruit are called Kirin)
Peaches (Green Peaches are common in the middle-east)
There are a few more which I cannot remember; I will add in edits.

I am of course open to the possibility that this is all random correlation and for every instance I've found here there are more instances in some other arbitrary pattern. But there seems to be something happening here.
There are 3 primary colors, that being red, yellow, and blue. Most foods are red and yellowish due to the fact that blue is very rare in nature. Here is an article you can check out Why is the colour blue so rare in nature? 
Now, you might ask, why is green so common then if green is a combination of blue and yellow, and blue is so rare? The pigmentation for green is usually chlorophyll, which is an important pigment that plants use in photosynthesis. That's why it is so common in leaves and other parts of the plant as well.