Skip to content

Instantly share code, notes, and snippets.

@dwinter
Created June 16, 2013 06:34
Show Gist options
  • Save dwinter/5791053 to your computer and use it in GitHub Desktop.
Save dwinter/5791053 to your computer and use it in GitHub Desktop.
f <- function(x,y) sin(x)/cos(y)
x <- seq(-5,5,0.1)
y <- seq(-5,5,0.1)
df <- expand.grid(x,y) #all possible combinations of x and y
df$value <- apply(df, 1, function(x) f(x[1], x[2]))
p <- ggplot(df, aes(Var1,Var2,fill=res>0))
p + geom_raster()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment