Why do distinct temperature layers form in bodies of water? This may not be the correct place to ask a question about limnology (which I just found out is the science of lakes) but it seems like the place most likely to produce a good answer.
In my diving lessons I learned that there is a layer of water in lakes where temperature suddenly drops. Judging from the pictures at Wikipedia: Thermocline the teacher was talking about the metalimnion which also sort of makes sense considering the depthof the lake he was talking about.
It is however still no clear to me why these layers form.
The article seems to suggest that the top layers warm-up due to sunlight while the bottom layer stays cold and there is little mixing because the colder water is denser.
But shouldn't that lead to a somewhat linear temperature gradient instead of layers?
Edit:
Here is a nice picture showing the different layers from loon lake:

 A: The gradient is not linear because the thermocline is produced by the absorption of solar radiation. When radiation is absorbed by a material, its intensity decreases exponentially with penetration depth, so exponentially more energy is deposited in the top layers than the bottom. Therefore, if there were no mixing at all, you would expect an exponential gradient in temperature, such that most of the solar energy would be absorbed by the top few cm of water. But waves driven by the wind, tides, and currents mix the top few cm of water with lower layers, down to roughly a few hundred meters, so that the warmth is somewhat more uniformly distributed and the temperature gradient is somewhat less than exponential. In very, very deep water, the pressure at lower depths is high enough to affect the heat capacity of seawater, which might change the temperature gradient (plus, there may be deep ocean currents responsible for mixing in lower layers).
So what you should see should basically be a distorted exponential curve, and that's essentially what most thermocline curves show.
A: The three layers are depicted here (from Wikipedia):

The top and bottom layers are distinguished by mostly constant temperature across their depth.
The top layer mixes due to external factors like wind.
The bottom layers mixes because all the water is close to its highest density and the density is approximately the same across the entire layer. Therefore,  very little energy is required to mix it.
The remaining middle layer is where the water shows the expected temperature drop.
An important point is that the three layers all exist for different reasons and are not caused by the same physical phenomenon and are not homogeneous.
A: Typically, the temperature of a lake is pretty uniform with depth in winter--the surface cools, driving convection, and even if there are periods with heat input at the surface, wind mixing keeps things homogenous.  In the summer, there is significant heat input from the sun.  Wind still mixes the surface, but the thermal stratification prevents the wind mixing from penetrating to great depth--there is not enough mechanical energy input to overcome the stability of the light water overlying heavy water. In your example figure, wind has mixed the surface layer down to about 5 meters.  This is typical: it's called a "mixed layer". 
