howto generate colors

Is there a way to let OpenGl gegerate colors similar to the texture coordinate generation ? I want to render a 3d graph where the higher a Vertex is the more should it turn from green to red.
My only idea would be to use a 3d texture with 2 planes, a red and a green one. This way I could use texgen functionality but this seems to be overkill.

Well, after thinking about it again the best solution seems to be a 1D texture but is there any way to let opengl generate color values at all ?

Lighting will generate colors for you.

You can also switch off lighting and just use colour3f to colour vertexs and smooth colours enabled to shade from red to blue. See HeNe tutorials for his pyramid (this has a different colour for each corner).