The median marks the second quartile, or 50th percentile: the threshold separating a dataset’s lower and higher halves. In a box plot, a perpendicular line makes this central value visible. section 6.4 section 6.4.1
Use the median when building distribution visualizations:
- Calculate it directly with d3.median(), passing an array of values such as salary data. section 6.4.1
- Calculate it alongside the first and third quartiles to describe the center and spread of a distribution. section 6.4
- Represent it with an SVG line positioned between the lower and higher halves of the dataset. section 6.4.4
Comparing salary distributions
Separate the survey salaries into women’s and men’s arrays, calculate each median and quartile set, and place a median line inside each box plot. The resulting visualization compares the central salary values as well as the distributions’ ranges. section 6.4.1 section 6.4.4
d3.median(femalesSalaries);
Inspect the direct D3 expression for calculating a dataset’s median. section 6.4.1






