Skip to content
Prev 155104 / 398513 Next

how to draw the legend about color from 3d picture

On 9/5/2008 8:06 AM, yk wrote:
I don't think there's an automatic way to do this (though probably some 
package provides one).

If you want to write your own, take a look at example(filled.contour). 
The legend it draws is done by this code:

     plot.new()
     plot.window(xlim = c(0, 1), ylim = range(levels), xaxs = "i",
         yaxs = "i")
     rect(0, levels[-length(levels)], 1, levels[-1], col = col)
     if (missing(key.axes)) {
         if (axes)
             axis(4)
     }
     else key.axes
     box()

(but it has done a lot of setup using layout() and par() before this).

Duncan Murdoch