Stomata regulate the supply of CO2 for photosynthesis and the rate of water loss out of the leaf. The presence of stomata on both leaf surfaces, termed amphistomy, increases photosynthetic rate, is common in plants from high light habitats, and rare otherwise. In this study I use optimality models based on leaf energy budget and photosynthetic models to ask why amphistomy is common in high light habitats. I developed an R package leafoptimizer to solve for stomatal traits that optimally balance carbon gain with water loss in a given environment. The model predicts that amphistomy is common in high light because its marginal effect on carbon gain is greater than in the shade, but only if the costs of amphistomy are also lower under high light than in the shade. More generally, covariation between costs and benefits may explain why stomatal and other traits form discrete phenotypic clusters.