liveBook · Manning

Probability distribution

As explained in D3.js in Action, Third Edition

A data distribution is the pattern of values and their frequencies or densities across a variable's possible range.

A probability distribution describes how often values occur within a variable’s possible range, or how likely values are to appear within particular ranges. Distribution visualizations turn that pattern into charts such as histograms, pyramid charts, box plots, and violin plots. section 6.0

Build a distribution visualization by:

  • Grouping data points into bins, usually equal-width ranges that collect values together. section 6.0 section 6.1
  • Passing the relevant values to D3’s d3.bin() generator, which returns bins containing data points and boundary values. section 6.1
  • Drawing a histogram to show frequency, or using box and violin plots to reveal medians, quartiles, averages, and distribution shape. section 6.0

Binning salary data

A salary dataset can be converted into bins with: const binGenerator = d3.bin().value(d => d.salary); const bins = binGenerator(data); Each resulting bin contains salary records, while x0 and x1 identify its lower and upper boundaries. The records can then drive a histogram. section 6.1

Figure 6.1 In this chapter, we’ll build four charts to visualize the salary distribution among data visualization practitioners based in the United States.
figure

Compare four distribution views of salaries for US-based data visualization practitioners. section 6.0

How D3.js in Action, Third Edition covers it

How deep it goes
Explains binning and D3 implementation, then applies histograms, box plots, pyramid charts, and violin plots.
Examples
Uses 788 survey respondents’ salaries, salary brackets, and role-based earnings as distribution examples.
What it assumes
Assumes a loaded dataset and basic D3 data handling while teaching bin construction through salary records.
What you can do after
Build it from scratch with D3 by preprocessing values into bins and rendering distribution charts.
How it connects
Connects probability distributions with bins, histograms, quartiles, medians, box plots, and violin plots.

Also explained in

Compare how 27 books explain probability distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.