Open jabrena opened 4 months ago
ggplot(mtcars, aes(x=hp, y=mpg, color=cyl, shape=cyl)) +
geom_point(size=3) +
geom_smooth(method="lm", aes(fill=cyl))
ggplot(mtcars, aes(x=hp, y=mpg)) +
geom_point(size=3, aes(color=cyl, shape=cyl)) +
geom_smooth(method="lm", aes(color=cyl, fill=cyl)) +
geom_smooth(method="loess", color="black", se=FALSE)
last_plot() + theme_bw()
plt <-
ggplot(mtcars, aes(x=hp, y=mpg, color=cyl, shape=cyl)) +
geom_point(size=3) +
geom_smooth(method="lm", aes(fill=cyl))
plt + facet_wrap(~cyl)
plt2 <- ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point(color = 'red', size=2) +
geom_smooth(method="loess") +
labs(y="Miles per gallon", x="Weight (1000 lbs.)") +
theme_classic(base_size = 16)
plt2 + geom_text(aes(label = rownames(mtcars)))
install.packages(“ggrepel”)
library(ggrepel)
plt2 +
geom_text_repel(aes(label = rownames(mtcars)))
mod <- loess( mpg ~ wt, data=mtcars)
resids <- residuals(mod)
mtcars$label <- ifelse(abs(resids) > 2.5,
rownames(mtcars), "")
plt2 + geom_text_repel(aes(label = mtcars$label))
names(plt)
class(plt)
library(gridExtra)