Mingshi Di
2017-03-05
Vis 1
library(ggplot2)
ggplot(data = mpg, aes(class)) + geom_bar(aes(fill = trans)) + labs(fill="Transmission")
Vis 2
ggplot(data = mpg, aes(x=manufacturer, y=hwy)) + geom_boxplot() + coord_flip() + ylab("Highway Fuel Efficiency (miles/gallon)")
Vis 3
library(ggthemes)
ggplot(data = diamonds, aes(price, colour = cut, fill = cut)) + geom_density(alpha = 0.1) + xlab("Diamond Price(USD)") + ylab("Density") + theme(legend.position="top") + ggtitle("Diamond Title Density") + theme(plot.title = element_text(face = "bold")) + theme_economist()
Vis 4
ggplot(data = iris, aes(x=Sepal.Length, y=Petal.Length)) + geom_point() + xlab("Iris Sepal Length") + ylab("Iris Petal Length") + ggtitle("Relationship between Petal and Sepal Length") + geom_smooth(method = lm) + theme_bw()
Vis 5
ggplot(data = iris, aes(x=Sepal.Length, y=Petal.Length)) + geom_point(aes(colour = Species)) + labs(xlab = "Iris Sepal Length", ylab = "Iris Petal Length", title="Relationship between Petal and Sepal Length", subtitle="Species level comparison") + geom_smooth(aes(colour = Species), method=lm, se=FALSE) + theme_classic() + theme(legend.position="bottom", axis.line=element_blank(), plot.title=element_text(family="Times"), plot.subtitle=element_text(family="Times"), axis.title=element_text(family="Times"), legend.text=element_text(family="Times"))