Heating or cooling a stable compositional gradient from the side