The green colour of any plant is because of the pigment called chlorophyll in which photosynthesis takes place and which is present in the chloroplast of the leaves.
Chloroplast is one of the type of plastids which is green in colour, in the same way there are two more plastids which has different colour they are leucoplast and chromoplast.
Leucoplast are white in color and generally they are ment for storage of starch.
Chromoplast has colour (chromo-color) since they have pigments like xanthophyll, caroteins etc., which will have different colour like red yellow etc...
Therefore depending upon the presence of plastids they will have colour.
Since spinach has chloroplast with chlorophyll it is green in color and papaya has chromoplast with xanthophyll it is yellow in color.
Visible light colors are a small part of the overall collection of waves on the electromagnetic spectrum. You can remember the order of teh light colors with respect to their corresponding wavelengths, from lowest to highest, by using the mnemonic "ROY G. BIV". The letters correspond to the colors, which are red, orange, yellow, green, blue, indigo, and violet.
When we see a particular color, such as spinach green or papaya yellow, what is happening is sunlight, which is composed of all the colors, is radiating upon the spinach and papaya. All the colors are absorbed except that specific colr, which is reflected back from the object. That is why spinach appears green, and papaya appears as yellow, because those specific colors are reflected, while all the other colors are absorbed. It should also be noted that all the colors combine to give what is known as "white light"; this may be demonstrated by taking a prism and allowing sunlight to shine through it. The result is a rainbow, showing the respective colors white light is made of.
Spinach is green because it is the leafy part of the plant, which perfoms photosynthesis and uses chlorophyll (which is green to absord red light).
Papaya is yellow for the same reason watermelon is red. So that animals (be they mammal or insect) will be attracted to/ recognize them so they will eat them and release the seeds (by dropping from their mouths or in excrement) onto the ground so the plant can reproduce.
The pigments are as follows:
Chlorophyll (a/b) is green
Xanthophylls are yellowish carotenoids
Carotenes are redish/orangey carotenoids
Although watermelon could be red because of iron content...