Reputation: 631
I want to color the picture I draw according to the value of z ,take example like this
x<-y<-seq(-2*pi, 2*pi, pi/15)
f<-function(x,y) sin(x)*sin(y)
z<-outer(x,y, f)
#contour(x,y,z,col="blue")
persp(x,y,z,theta=30, phi=30, expand=0.7,col=heat.colors(25))
if I want to color this picture in rainbow color or heat.colors the large the value of z, the dark the color , what should I do,how to control the color set
thank you all
Upvotes: 2
Views: 960
Reputation: 121608
In addition to the example in the help , you can use drape.plot
from fields
package which by default have colors assigned from a color bar based on the z values.It calls drape.color
followed by persp and finally the legend strip is added with image.plot.
ncol <- 5
library(fields)
drape.plot( x,y,z, col=rainbow(nbcol))
Upvotes: 2