Here is an example of what is desired, only the result wouldn't be a contour plot, but a ListDensityPlot. The arguments would be a gradient and a list of numbers.
Here is a transcription of my related answer to the problem at hand - hopefully I understand the question correctly:
Take an example data set:
Use the function definitions I posted earlier, except that I replace
With this, the example plot is now
If this turns out to be close to what is desired, one could modify it further to allow a list of tick marks to be provided as an argument. Right now I only take the number of marks and divide the automatically determined plot color range equally.
Let's say this is your
Here's a legend for it:
Now put them together:
The underlying logic can be generalized into a function:
I know this is an old question, but just in case:
Now in Mathematica 9.0 or higher, PlotLegends does this automatically.
Using Grid results in relatively terse code, eg:
In general I find Row, Column and Grid enable building composite graphics that also use expressions.