1. Vis 1

This graphic is a traditional stacked bar chart. This graphic works on the mpg dataset, which is built into the ggplot2 library.

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

data <- anscombe

Vis 2

This boxplot is also built using the mpg dataset.

vis2 <- ggplot(mpg,aes(manufacturer,hwy))
vis2 + geom_boxplot() + coord_flip() + xlab("Vehicle Manufacturer") + ylab("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.

library("ggthemes")
## Warning: package 'ggthemes' was built under R version 3.4.4
vis3 <- ggplot(diamonds, aes(price, colour = cut,fill = cut)) 
vis3 + geom_density(alpha = 0.2) + theme(legend.position="top",plot.background = element_rect(fill  = "slategray2"),legend.background = element_rect(fill  = "slategray2"),panel.background = element_rect(fill  = "slategray2"),panel.grid.minor.x = element_blank(),panel.grid.major.x = element_blank(),panel.grid.minor.y = element_blank(),axis.ticks.y = element_blank(), axis.line.x  = element_line(size=1),axis.ticks.length = unit(0.25,"cm")) + xlab("Diamond Price (USD)") + ylab("Density") + labs(title = "Diamond Price Density")

Vis 4

For this plot we are changing vis idioms to a scatter plot framework.

vis4 <- ggplot(iris,aes(Sepal.Length, Petal.Length))
vis4 + geom_point() + geom_smooth(method = lm) + theme_minimal() + xlab("Iris Sepal Length") + ylab("Iris Petal Length") + labs(title = "Relationship between Petal and Sepal Length")

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 modicitations.

vis5 <- ggplot(iris,aes(Sepal.Length, Petal.Length, colour = Species))
vis5 + geom_point() + geom_smooth(method = lm, se = FALSE) + theme_classic() + xlab("Iris Sepal Length") + ylab("Iris Petal Length") + labs(title = "Relationship between Petal and Sepal Length", subtitle = "Species level comparison") + theme(legend.position="bottom",axis.line = element_blank())