Natural and sexual selection act together to structure patterns of MHC diversity. MHC allelic richness under disassortative mating (RM, blue; h = 0, green; h = 1, red) and host–pathogen coevolution (Pon, solid; Poff, dashed) for (a) Ne = 1000 and (b) Ne = 5000 hosts. Error bars denote bootstrapped confidence limits (100 replicates) for the mean, calculated every 100 generations after simulations reached mutation–selection equilibrium. (c) The relative importance of natural and sexual selection is dependent on population size. Plots show mean allelic richness after equilibrium for host populations of variable size. Error bars denote bootstrapped confidence limits (100 replicates) for the mean, calculated for the final 500 generations after simulations reached mutation–selection equilibrium. The pathogen mutation rate was fixed to 2 × 10−3 per antigen per generation for all simulations shown.