Vis 1 This graphic is a traditional stacked bar chart. This graphic works on the mpg dataset, which is built into the ggplot2 library. This means that you can access it simply by ggplot(mpg, ….). There is one modification above default in this graphic, I renamed the legend for more clarity.

library("ggplot2")
## Warning: package 'ggplot2' was built under R version 3.4.4
p1 <- ggplot(mpg, aes(class))
p1 <- p1 + geom_bar(aes(fill=trans)) 
p1 + scale_fill_discrete(name = "Transmission")

Vis 2 This boxplot is also built using the mpg dataset. Notice the changes in axis labels, and an altered theme_XXXX

library("ggplot2")
p2 <- ggplot(mpg,aes(manufacturer,hwy))
p2 + geom_boxplot()+coord_flip()+labs(x="Vehicle Manufacturer", y="Highway Fuel Efficiency(miles/gallon) ")+theme_classic()

Vis 3 This graphic is built with another dataset diamonds a dataset also built into the ggplot2 package. For this one I used an additional package called library(ggthemes) check it out to reproduce this view.

library("ggplot2")

Vis 4 For this plot we are changing vis idioms to a scatter plot framework. Additionally, I am using ggplot2 package to fit a linear model to the data all within the plot framework. Three are edited labels and theme modifications as well.

if (!require("ggthemes")) {
  install.packages("ggthemes")
}
## Loading required package: ggthemes
## Warning: package 'ggthemes' was built under R version 3.4.4
library(ggthemes)
library(ggplot2)
p3 <- ggplot(diamonds, aes(x=price,color=cut,fill=cut))
p3 <- p3 + geom_density(alpha=0.2) + labs(x="Diamond Price(USD)", y="Density", title="Diamond Price Density")
p3 + theme_economist() + scale_colour_economist()

Vis 5 Finally, in this vis I extend on the last example, by plotting the same data but using an additional channel to communicate species level differences. Again I fit a linear model to the data but this time one for each species, and add additional theme and labeling modifitations.

library("ggplot2")
p4 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length))
p4 <- p4 + geom_jitter() + labs(x="Iris Sepal Length", y="Iris Petal Length", title="Relationship between Petal and Sepal Length")
p4 <- p4 + geom_smooth(method=lm)
p4 + theme_minimal()