Line Graphs

Explore line graphs and how to plot them in R.

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 package, which is the weather data frame.

Let’s explore the weather data frame by running print(weather) and glimpse(weather).

Get hands-on with 1400+ tech skills courses.