Installing packages

installed.packages("ggplot2")
##      Package LibPath Version Priority Depends Imports LinkingTo Suggests
##      Enhances License License_is_FOSS License_restricts_use OS_type Archs
##      MD5sum NeedsCompilation Built
installed.packages("ggthemes")
##      Package LibPath Version Priority Depends Imports LinkingTo Suggests
##      Enhances License License_is_FOSS License_restricts_use OS_type Archs
##      MD5sum NeedsCompilation Built
library(ggplot2)
library(ggthemes)

Vis 1

g <- ggplot(mpg, aes(class))
g + geom_bar(aes(fill = trans)) + labs(fill = "Transmission")

Vis 2

p <- ggplot(mpg, aes(manufacturer, hwy))
p + geom_boxplot() + coord_flip() + xlab("Vehicle Manufacturer") + ylab("Highway Fuel Efficiency (miles/gallon)") + theme(panel.background = element_rect(fill = 'white')) +theme(axis.line = element_line(size = 0.5, color = "black"))

Vis 3

p3 <- ggplot(diamonds, aes(x=price, group = cut, fill = cut, color = cut)) + geom_density(adjust=1, alpha = 0.3) + labs(x="Diamond Price (USD)",y="Density")
p3 + theme_economist() + ggtitle("Diamond Price Density")

Vis 4

p4 <- ggplot(iris, aes(Sepal.Length, Petal.Length)) + geom_point() + geom_smooth(method = "lm") + labs(x="Iris Sepal Length",y="Iris Petal Length")
p4 + ggtitle("Relationship between Petal and Sepal Length") + theme(panel.background = element_rect(fill = 'white')) + theme(panel.grid.major = element_line(colour="grey", size = (0.1)))

Viz 5

p5 <- ggplot(iris, aes(Sepal.Length, Petal.Length, color = Species)) + geom_point() + geom_smooth(method = "lm", se = FALSE) + labs(x="Iris Sepal Length",y="Iris Petal Length")
p5 + ggtitle("Relationship between Petal and Sepal Length", subtitle = "Species level comparison") + theme(panel.background = element_rect(fill = 'white')) + theme(panel.grid.major = element_line(colour="white", size = (0.1))) + theme(legend.position="bottom") + theme(legend.key = element_rect(fill = "white")) + labs(x="Iris Sepal Length",y="Iris Petal Length") + theme(axis.title = element_text(family = "Times")) + theme(plot.title = element_text(family = "Times", size = (15))) + theme(legend.text = element_text(family = "Times")) + theme(legend.title = element_text(family = "Times")) + theme(plot.subtitle = element_text(family = "Times"))