UNIVARIATE

Univariate graphs: These graphs are useful if you have a single column you’re trying to visualize. Each chapter in the book starts by simulating the data we expect to see first. Then, we change the data (a small sample, a hidden second group, or a heavy tail) to show something unexpected. These changes are easier to spot when we’re only looking at a single variable or column; they’re harder to see when we’re looking at two or more.

Bar graphs

A bar graph displays and compares data in different categories. Each category gets a rectangular bar, and the bar’s length or height shows the quantity it represents. Bar graphs can be either vertical or horizontal. In a vertical bar graph (the most common), the vertical axis shows the quantities being measured and the horizontal axis lists the categories. When we compare multiple variables, bar graphs often include a legend (usually to the side of the graph) that explains the colors or patterns.

Histograms

A histogram shows how numerical values are spread out over a continuous interval. In contrast to bar graphs, histograms don’t have gaps between the bars, which indicates that the data covers a continuous interval. The bars show the frequency of data points within a specific range, called ‘bins.’ The x-axis displays the range of the measured variable, while the y-axis represents the frequency of observations.

Frequency polygons

A frequency polygon is similar to the histogram, but it uses points connected by straight lines instead of bars. We often use frequency polygons to compare distributions across groups. Each point sits above the midpoint of an interval on the x-axis, at the height of that interval’s count. Lines connect the points. The legend at the top or side of the plot is used to differentiate between variables.

Dot plots

A dot plot shows each data point as a dot on a single line. Dot plots work well for small to moderate datasets because they help show us patterns, clusters, gaps, and outliers. In a dot plot, each dot represents a piece of data. Depending on what we’re measuring, the dots either stack up over categories or spread out along a line.

Density plots

A density plot represents a variable’s distribution as a smooth, continuous curve. Similar to the histogram, but it swaps the bars for a smooth curve to show where values are concentrated over the interval. Density plots can help us compare several distributions on the same graph. The area under the curve represents the total probability of the data. These plots often display multiple curves in different colors, with a legend (typically on the side) to explain each curve.

Box plots

Box plots, or box-and-whisker plots, use five values to summarize the data: the minimum, the first quartile (25th percentile), the median, the third quartile (75th percentile), and the maximum. The plot looks like a box with a line in the middle. The line is the median, and the box goes from the first quartile to the third quartile. Lines called whiskers go from the box to the most extreme values within 1.5 times the box’s length (the interquartile range). If there are any unusual points beyond that, they are shown as dots outside the whiskers.

Box plots are helpful if you want to see if there are any unusual points or if you want to compare different groups of data.

Violin plots

Violin plots help us see how data is distributed and how likely a specific value will occur. They are similar to box plots but with a rotated kernel density plot on each side. The plot’s width at different values shows how often that value appears in the data. Broader parts of the violin indicate that the value appears more often.

We can use these plots to compare distributions across categories. They often include a box plot inside the violin to show the median and interquartile range.