library(ggplot2)
data(mpg)

# 1
a <- ggplot(mpg, aes(class, fill = trans))+ geom_bar(position = "stack")
a  + labs(fill = "Transmission")

# 2
b <- ggplot(mpg, aes(manufacturer, hwy))+ geom_boxplot() + coord_flip()
b + xlab("Vehicle Manufacturer") + ylab("Highway Fuel Efficiency (miles/gallon)") + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))

# 3
library(ggthemes) 
data(diamonds)

c<-ggplot(diamonds, aes(price, fill = cut, colour = cut)) + geom_density(alpha = 0.1) 

c + xlab("Diamond Price (USD)") + ylab("Density") +ggtitle("Diamond Price Density") +theme_bw()+theme(legend.position="top", panel.border = element_blank())+ theme_economist() 

# 4
data(iris)
d <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point() + ggtitle("Relationship between Petal and Sepal Length")

d + xlab("Iris Sepal Length") + ylab("Iris Petal Length") + geom_smooth(method="lm") + theme_bw()+ theme(panel.border = element_blank())

# 5
e <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length,  colour = factor(Species))) + geom_point() + labs(title = "Relationship between Petal and Sepal Length", subtitle = "Species level comparison") + theme_bw()+ theme(panel.border = element_blank())

e + xlab("Iris Sepal Length") + ylab("Iris Petal Length") + geom_smooth(method="lm", se = FALSE) +theme(legend.position="bottom", panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),)+ labs(colour="Species")