I'm trying to draw a plot in R:
Here's my code:
g<- function(x,y)
+ x**2+y**2-3*x+y+2
gb<- function(x) g(x[1],x[2])
x <- seq(-2,2,len=51)
y <- seq(-2,2,len=51)
gz<-outer(x,y,g)
contour(x,y,gz)
polygon(c(0,0,1),c(1,2,1))
The above code works fine but when I try to add color to my plot using the following code:
g<- function(x,y)
+ x**2+y**2-3*x+y+2
gb<- function(x) g(x[1],x[2])
x <- seq(-2,2,len=51)
y <- seq(-2,2,len=51)
gz<-outer(x,y,g)
contour(x,y,gz)
polygon(c(0,0,1),c(1,2,1),
+ col="red",
+density=c(30,40))
I get this error:
Error: unexpected '=' in:
"polygon(c(0,0,1),c(1,2,1),
+ col="