#title: "Proj 3 by Bernard"

library(ggplot2)

#Part a
ggplot(mpg, aes(manufacturer)) + labs(title = "Manufacturers Bar Graph") +
  theme(axis.text.x = element_text(angle=90)) + 
  geom_bar(stat = "count")

#part b  
ggplot(mpg, aes(year)) + labs(title = "Year Bar Graph") + 
  geom_bar(stat = "count")

#Part c
ggplot(mpg, aes(x=displ, color=as.character(cyl))) +
  geom_density() + labs(title="Density Plot", 
                    subtitle="Engine Displacement by Cylinder",
                  x="Engine Displacement", y="Density", color="cylinder") +
  theme(plot.background = element_rect(fill="white"))

ggplot(mpg, aes(x=cty, color=as.character(cyl))) +
  geom_density() + labs(title="Density Plot", 
                        subtitle="City Mileage by Cylinder",
                        x="City Mileage", y="Density", color="# of Cyl")+ 
  theme(plot.background = element_rect(fill="gray"))

ggplot(mpg, aes(x=hwy, color=as.character(cyl))) +
  geom_density() + labs(title="Density Plot", 
                        subtitle="Highway Mileage by Cylinder",
                        x="Miles per gallon", y="Density", color="Cylinder") + 
  theme(plot.background = element_rect(fill="gray"))

#Part d
ggplot(mpg, aes(y = displ, x = as.factor(cyl), fill=as.factor(cyl))) +
  geom_boxplot() + labs(title="Box Plot",
                        subtitle="Engine Displacement by Cylinder", 
                        x="Cylinder",y="Engine Displacement") + 
  theme(plot.background = element_rect(fill="gray"), 
        legend.position = "right")