[This article was first published on YGC » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
HardOCP has an image with an equation which apparently draws the Batman logo.
This function is very delightful for drawing such a graph, but write it down in latex is very tedious.
As a product of factors is 0 if and only if any one of them is 0, multiplying these six factors puts the curves together. This graph is no more than the combination of six curves.
All these six curves are very simple, for instance, the first factor is the ellipse
Here’s what I got from the equation using ggplot2…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | require(ggplot2) f1 <- function(x) { y1 <- 3*sqrt(1-(x/7)^2) y2 <- -3*sqrt(1-(x/7)^2) y <- c(y1,y2) d <- data.frame(x=x,y=y) d <- d[d$y > -3*sqrt(33)/7,] return(d) } x1 <- c(seq(3, 7, 0.001), seq(-7, -3, 0.001)) d1 <- f1(x1) p1 <- ggplot(d1,aes(x,y)) + geom_point(color="red") x2 <- seq(-4,4, 0.001) y2 <- abs(x2/2)-(3*sqrt(33)-7)*x2^2/112-3 + sqrt(1-(abs(abs(x2)-2)-1)^2) p2 <- p1 + geom_point(aes(x=x2,y=y2), color="yellow") x3 <- c(seq(0.75,1,0.001), seq(-1,-0.75,0.001)) y3 <- 9-8*abs(x3) p3 <- p2+geom_point(aes(x=x3,y=y3), color="green") x4 <- c(seq(0.5,0.75,0.001), seq(-0.75,-0.5,0.001)) y4 <- 3*abs(x4)+0.75 p4 <- p3+geom_point(aes(x=x4,y=y4), color="steelblue") x5 <- seq(-0.5,0.5,0.001) y5 <- rep(2.25,length(x5)) p5 <- p4+geom_point(aes(x=x5,y=y5)) x6 <- c(seq(-3,-1,0.001), seq(1,3,0.001)) y6 <- 6 * sqrt(10)/7 + (1.5 - 0.5 * abs(x6)) * sqrt(abs(abs(x6)-1)/(abs(x6)-1)) - 6 * sqrt(10) * sqrt(4-(abs(x6)-1)^2)/14 p6 <- p5+geom_point(aes(x=x6,y=y6), colour="blue") p <- p6+theme_bw() print(p) |
Related Posts
To leave a comment for the author, please follow the link and comment on their blog: YGC » R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.