x <- c( 1, 1.5, 2, 3, 4.2, 5.0, 6.1, 5.3, 4.5, 0.9, 2.1, 4.3)
d <- c( 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1)
f<-function( x) { x-3.7}
myfun5 <- function( x) {
x^2-16.5
}
# construnct g as a LIST!
g=list( f1=f,f2=myfun5) ;
kmc.solve( x,d,g) ->re0;
#plotkmc2D(re0) ->ZZ; # run this to generate contour plot
#Advanced PLOT option using ggplot2: not run
#library(reshape2)
#volcano3d <- melt(ZZ$Z)
#names(volcano3d) <- c("x", "y", "z")
#volcano3d$x <- ZZ$X[volcano3d$x];
#volcano3d$y <- ZZ$Y[volcano3d$y];
#### Plot: use ggplot2 ####
#library(ggplot2)
# v <- ggplot(volcano3d, aes(x, y, z=z));
# v + geom_tile(aes(fill = z)) +
# stat_contour()+
# scale_fill_gradientn("Custom Colours",colours=grey.colors(10));
#### Plot: use qplot ####
#qplot(x, y, z = z, data = volcano3d, stat = "contour", geom = "path")
Run the code above in your browser using DataLab