Anscombe's Quartet with simple-statistics and d3js v4 -
Anscombe's Quartet is visualized as four separate scatterplots, each displaying a series of 11 data points loaded from a CSV file. The charts share identical axes, scales, and styling—pink circles on a cream background—and each is labeled Series 1 through 4. Using the simple-statistics library, the same summary statistics (mean, sample variance, and correlation coefficient) are calculated for every series and printed beneath each plot, showing nearly identical values. The d3.js v4 code also fits and draws a light-blue regression line per plot, emphasizing how the four datasets, though statistically similar, have very different graphical structures. The example is implemented entirely in SVG, with no animation, and demonstrates the importance of visualizing data before relying on descriptive statistics.
AI-generated descriptionAnscombe's Quartet
I use Frank Anscombe's quartet alot when teaching data visualisation courses: Despite the arrival of the brilliant Datasaurus Dozen, it's still a powerful illustration of the drawback of relying solely on basic descriptive statistics to summarise data. The data in all 4 of the graphs in the quartet are virtually indentical when using standard descriptive methods - the graphs reveal the truth. Looking at your data before analysing it is something that Anscombe was passionate about:
"Most kinds of statistical calculation rest on assumptions about the behaviour of the data. Those assumptions may be false, and then the calculations may be misleading. We ought always to try to check whether the assumptions are reasonably correct; and if they are wrong we ought to be able to perceive in what ways they are wrong. Graphs are very valuable for these purposes."
Frank Anscombe, Graphs in Statistical Analysis (1973)
I became increasingly embarassed that I kept using screengrabs from Wikipedia in my course slides, so I decided to create my own version using d3js and simple-statistics, now updated to use d3js v4 and simple-statistics v4.1.