Dica dos professores Erik e Hilton da UFPB.
install.packages("ggplot2")
instala <- function(pacote) {
if(is.element(pacote, installed.packages()[,1])==FALSE) {
install.packages(pacote,repos='http://www.vps.fmvz.usp.br/CRAN/')
}
}
instala('ggplot2')
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)
install.packages("ggplot2")
instala <- function(pacote) {
if(is.element(pacote, installed.packages()[,1])==FALSE) {
install.packages(pacote,repos='http://www.vps.fmvz.usp.br/CRAN/')
}
}
instala('ggplot2')
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)
Comentários
Postar um comentário