Plastic colored ...
Usually, they use the plastic in the form of raw color pellets. Then they add the "masters", which are other pellets of the same plastic (more or less) but with an high concentration of dye or pigments, following the recipe to get the right color. They mix that in a tank and pour the pellet's blend in the molding machine.
For big volumes, the plastic maker can do that for you, so you don't have to worry about the mixing and be sure to get the good and homogeneous color.
There are pigments which are a solid finely divided, like dust, often minerals or metals. The other form is the dyes, which are chemical products with a liquid-like behaviour in the plastic (when melted). The first ones are about completely opaque, the last ones are more translucent or even transparent.
The light is the murderer of plastics, overall the polyethylene family (others are less sensitive). The light breaks the bonds in the giant molecules, making them smaller and smaller, thus rending the plastic brittle, or even actually breaking the part in small bits.
If you can stop the light soon enough in the wall, you keep a fair amount of good plastic with all its properties. With light/translucent colors, the sun light is reflected/transmitted (at least partially) inside the plastic, wrecking deeply the molecules. The color itself can be destroyed, like often the red for example. With very dark/black pigments, most of the light is absorbed in the first layer, converted into heat and doesn't have a chance to penetrate. The plastic molecules are still destroyed at the surface, but under the grits of pigment, they stay almost untouched. So, with enough concentration of pigments and not too much mechanical wear on the surface, the plastic can stand a long time in the light.