Understand the idea
A line chart puts something ordered along the bottom, most often dates, and a measurement up the side, and joins the points in that order. It is the natural picture of anything that changes over time: weekly sales, monthly rainfall, the waiting time at each clinic visit.
Read the shape, not single points. A steady climb, a level that steps up, a wave that repeats each year, one spike: those are what a line shows well. One high week next to a low one is usually ordinary ups and downs.
Sometimes several rows share one X, for example three shops in the same week. Then KernelStats draws one point per week, the mean of those rows, with a shaded band around it. The band is a 95% confidence interval for that mean: a range of plausible values for the average, not the spread of the individual shops. It is wide when few rows share the week or when they differ a lot, and there is no band where only one row has that week.
A blank value leaves a gap in the line rather than a straight line drawn across it, so you can see where data are missing. A dashed line at the median turns a single series into a run chart: points that stay above or below it for a long stretch are worth a second look.
Practitioner explanation
KernelStats sorts the rows by X (stable, so ties keep table order; Sort by X can be turned off) and reads X as a date when the column is a date type or text in one date shape for the whole column (2024-01-15, 2024/01/15, 1/15/2024 month first unless a first field exceeds 12, 2024-01, Jan 2024); other text is an ordered category in first-appearance order, and an empty X means row order. Y may be several numeric columns (one line each) or one column split by a group of at most 12 levels, not both.
When rows share an X the default summary is the mean with a two-sided 95% t interval, mean ± t(0.975, n − 1) × s / √n, drawn only where n ≥ 2 (a lone interval between gaps is an error bar). The same summary choices as the bar chart are offered (mean, median, sum, minimum, maximum, count of non-blank values) or every row joined, which zig-zags at a repeated X and draws a warning. The interval treats the rows at one X as independent; repeated measurements of the same units, or rows that are already averages, make it too narrow. A blank Y breaks the line by default (connectgaps off); the option joins across it instead. The reference line is each line's mean or median of the plotted points; KernelStats does not run the runs tests of a formal run chart.
The chart describes the data and tests nothing. For a trend claim fit a regression on time or a time-series model (ARIMA, exponential smoothing), remembering that autocorrelated residuals invalidate ordinary least-squares standard errors; for process change use a control chart, whose limits come from the process's own variation. Python (matplotlib), R (base graphics) and MATLAB exports apply the same sorting, summary and gap rules and print the points they draw.
When to use it
Consider it when
You want to see how a measurement changes over time or along an ordered scale: a trend, a seasonal pattern, a run chart, or several series compared on one chart.
Use caution when
X has no order (regions, colors, product lines): a line implies that neighboring points are connected, so use a bar chart or a boxplot. Or you need a statement about whether a change is real: use a regression on time, a time-series model or a control chart.
Formulas and symbols
95% interval for the mean at one X
n_x, y-bar_x and s_x are the number, mean and sample standard deviation of the non-blank Y values of the rows sharing that X (drawn only when n_x is at least 2).
Assumptions and checks
- If the rows at one X are not independent (the same shop measured twice, or rows that are already averages), the shaded band understates the uncertainty of the mean.
In KernelStats: Not checked: the card cannot tell from the data whether rows at one X are independent units. It states n per point in the hover and the table.
- A text date column with mixed shapes (2024-01-05 and 1/12/2024) is not read as dates, so the axis becomes categories in first-appearance order and uneven spacing is hidden.
In KernelStats: The axis shows how X was read (a date axis or categories), and the card warns about a text X with many values; fix the column's type to Date or write the dates in one shape.
Alternatives
- Bar Chart (Bar Chart). X is a set of unordered categories, or you want one summary bar per category rather than a path.
- I-MR Chart (I-MR Chart (Individuals & Moving Range)). The series is a process measured over time and you want to know whether a point or a run is beyond ordinary variation, with limits computed from the data.
- Scatter Plot (Scatter Plot). X is a measurement rather than an ordering (height against weight): joining the points in X order would invent a path that is not in the data.
Worked example
Scenario
airquality, X = Month, Y = Temp (153 days; several days share each month), default summary (mean and 95% CI)
Result
May 65.55 °F [63.03, 68.06] (n = 31), June 79.10 [76.64, 81.56] (30), July 83.90 [82.32, 85.49] (31), August 83.97 [81.55, 86.38] (31), September 76.90 [73.78, 80.02] (30)
Interpretation
The mean daily high rises from May to a plateau in July and August and falls in September; the bands are the uncertainty of each month's mean, not the spread of the days, and consecutive days are not independent, so they are, if anything, too narrow.
Dataset: airquality.csv
Common misconceptions
Misconception
The line goes up at the end, so sales are increasing.
Correction
A line chart tests nothing. Short series wander up and down by chance; fit a regression on time or a time-series model before saying a trend is real.
Misconception
The shaded band shows the range of the data at each week.
Correction
The band is a 95% confidence interval for the mean of the rows at that X. Individual rows spread much wider than the band.
Misconception
When two lines cross, one group has overtaken the other.
Correction
Only in this sample, and possibly by chance; lines that cross or separate may differ by no more than noise. Compare the bands and use a model with group and time to test it.
References
- NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.3.16 Run sequence plot, NIST/SEMATECH (2012), §1.3.3.16.
