ACTL1101 Lecture Notes - Lecture 9: Empirical Distribution Function, Confidence Interval, Box Plot
Document Summary
It is a natural way of creating plots. It allows advanced visualisation in a simple way. The basic function is ggplot() ggplot(raw_data: an empty plot is created, a dataset is supplied, but with no further instruction on how the data should be presented, hence nothing is displayed. Importantly, the data set supplied (here raw_data") must be a data frame. Another type of visual layer you can add with ggplot2 is a stat". We can color and re-size the dots: the color can be used to categorise observations, different states" in the current example, the sizes can be used to indicate numerical values, different. Popolation densities" in the current example ggplot(midwest, aes(x=area, y=poptotal)) + geom_point(aes(col=state, size=popdensity)) + xlim(c(0, 0. 1)) + ylim(c(0, 500000)) + theme(text = element_text(size=20)) #make axis bigger. ## warning: removed 15 rows containing missing values (geom_point). 500000 & midwest > 0. 01 & midwest < 0. 1, ] ggplot(midwest, aes(x=area, y=poptotal)) + geom_point(aes(col=state, size=popdensity)) +