The sample space is split into disjoint classes A1, …, Ak with prior probabilities P(Ai), and we observe an event B whose probability P(B|Ai) depends on the class. In the square, each class is a column whose width is its prior and whose shaded height is P(B|Ai): the shaded area is P(B) (the law of total probability), and the posterior P(Ai|B) is the share of the shaded area that lies in column i (Bayes' theorem). A test that is right 90% of the time therefore says little when the condition it detects is rare: the shaded area is dominated by the wide column of healthy people.
Simulation: each individual's class is drawn from the priors, then B occurs with probability P(B|class); the bottom-right panel follows the proportion of the tracked class among those in whom B occurred, which settles on the posterior. Moving the base-rate slider changes the tracked class's prior and rescales the other priors in proportion, keeping their ratios.
code/ch01_probability.py (bayes, positive_predictive_value, bayes_demo_sim, supplementary Figure 1.S5).