We report on the first case in which sequestered secondary plant compounds determine an insect's external appearance in the ultraviolet spectrum and thereby influence visually mediated mate choice. Larvae of the common blue butterfly Polyommatus icarus specifically sequester flavonoids in different amounts and types, depending on the part or species of food plant. During late pupal development the majority of ultraviolet-absorbing flavonoids are deposited in the wing scales. The flavonoid content of the larval diet thereby determines ultraviolet wing patterns. In laboratory and field experiments, male butterflies clearly preferred flavonoid-rich, ultraviolet-absorbing female dummies. This preference is mediated visually by the ultraviolet pattern of the wings. Food-plant parts and species vary in value as a food source, so ultraviolet wing patterns may signal mate quality and are not a species-specific characteristic. We discuss the use of principal component analysis in analysing spectral data in the context of visual communication. We propose the alternative application of confidence intervals of averaged spectra as a novel straightforward statistical method for comparing groups of spectra in a manner that is independent of assumptions about the visual system of the receiver. In addition, they can be used to give confidence intervals to derived measures of colour such as quantum catch by photoreceptors.