函数摘自Matrix67的博客
去你的七夕!敲代码比追女孩什么的有意思多了!
a <- seq(-5, 5, by=0.01)
b <- seq(-5, 5, by=0.01)
df <- transform(setNames(expand.grid(a, b), c("x", "y")),
ueq = (17*x^2 + 17*y^2 - 16*y*abs(x) + 150/abs(10*x + sin(10*y)) < 225) )
color <- ifelse(df$ueq == TRUE, 1 , 0)
data <- cbind(df,color)
library(ggplot2)
ggplot(data,aes(x, y, fill = color)) +
geom_raster() +
scale_fill_gradient(low = "white", high = "firebrick3") +
theme_classic() +
theme(legend.position = "none") +
annotate("text", x = 0, y = -4,
label = "17*x^2 + 17*y^2 - 16*y*abs(x) + frac(150, abs(5*x+sin(5*y))) <225",
parse = TRUE)
![17015091-361aa8e161d22c30.png](https://upload-images.jianshu.io/upload_images/17015091-361aa8e161d22c30.png)
转载于:https://www.jianshu.com/p/7bc0e4d34584