One of the most fascinating things about soap bubbles is the colors. Soap bubbles are thin enough to be able to affect the light that hits them. So you see e.g. blue, yellow and green colors in the bubbles, even though you make soap bubbles in the white light from the sun. And normally you see several colors at the same time in the same bubble.
The bubbles in the image above are illuminated with white light, which contains all colors. That is the reason that we are able to see the colors of our clothes when we illuminate it with white light. In order to understand how the colors are created, we will first focus on a bubble illuminated with only one color (monochrome light). You are able to see this color in some places and black in other places. This is because the thickness of the bubble wall is different in different areas. So it is the thickness of the bubble wall that affects for whether the yellow light is extinct or not.
The color of the bubbles varies between yellow and black in the vertical direction, whereas a constant color is found in horizontal layers or belts. The reason is that the thickness of the soap films varies in the vertical direction, but not in the horizontal direction. Gravity drags the liquid in the soap films downwards so that they get thicker in the bottom and thinner in the top.
The belts as found for the yellow light is also appearing when illuminating with other colors. The thickness and location of the belts depend on the color of the light. Illumination of a bubble using red followed by blue light is presented below.
When a bubble is illuminated with both red and blue light at the same time it is possible to see both colors (red and blue individually), absence of both colors (black), and a mix of the colors (magenta).
The color of a soap bubble therefore depends on the thickness of the soap film. Many colors can be seen when the bubble is illuminated by all colors (white light).
If we take a closer look at a soap film hit by a ray of light it is found that the ray will be partly reflected and partly transmitted (go through). The transmitted part of the ray will be reflected at the opposite side of the water layer of the soap film. The figure presents the most important rays of light in this relation. The interaction between the reflected light rays gives the beautiful colors of soap bubbles.
The rays of light enhance or dampen each other depending on the thickness of the soap film. Therefore it is possible to use the color in a given place to estimate the thickness of the soap film.
How the colors appear is further described on the page on thin film interference.