Line Graphs
Explore how to use ggplot2 to create line graphs that visualize relationships between two numerical variables when the x-axis has an inherent order such as time. Understand filtering datasets and mapping variables to aesthetics to produce clear time series plots.
We'll cover the following...
Line graphs—one of the 5NGs—show the relationship between two numerical variables when the variable on the x-axis, also called the explanatory variable, is of a sequential nature. In other words, there’s an inherent ordering to the variable. The most common examples of line graphs have some notion of time on the x-axis, such as hours, days, weeks, years, etc. Since time is sequential, we connect consecutive observations of the variable on the y-axis with a line. Line graphs that have some notion of time on the x-axis are also called time series plots. Let’s illustrate line graphs using another dataset in the nycflights13 ...