Indifference curves with filled contours

Hi, I am new to R and trying to replicate the following image.
image

I have been able to make the indifference curves but cant seem to add the color hue. I tries using ggplot but that does not allow me to add the indifference lines.

Any help is appreciated.

So far this is what i have tried

u <- function(x, y){
x^(1/2)*y^(1/2)
}
x <- seq(0, 10,0.1)
y <- seq(0, 10,0.1)
a <- c(2, 4, 6)

p<- outer(x, y, u)
persp(x, y, outer(x, y, u), ticktype="detailed")
p<- contour(x, y, outer(x, y, u), levels=a, drawlabels = FALSE)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.