The adult abdomen of Drosophila is a chain of anterior (A) and posterior (P) compartments. The engrailed gene is active in all P compartments and selects the P state. Hedgehog enters each A compartment across both its anterior and posterior edges; within A its concentration confers positional information. The A compartments are subdivided into an anterior and a posterior domain that each make different cell types in response to Hedgehog. We have studied the relationship between Hedgehog, engrailed and cell affinity. We made twin clones and measured the shape, size and displacement of the experimental clone, relative to its control twin. We varied the perceived level of Hedgehog in the experimental clone and find that, if this level is different from the surround, the clone fails to grow normally, rounds up and sometimes sorts out completely, becoming separated from the epithelium. Also, clones are displaced towards cells that are more like themselves: for example groups of cells in the middle of the A compartment that are persuaded to differentiate as if they were at the posterior limit of A, move posteriorly. Similarly, clones in the anterior domain of the A compartment that are forced to differentiate as if they were at the anterior limit of A, move anteriorly. Quantitation of these measures and the direction of displacement indicate that there is a U-shaped gradient of affinity in the A compartment that correlates with the U-shaped landscape of Hedgehog concentration. Since affinity changes are autonomous to the clone we believe that, normally, each cell's affinity is a direct response to Hedgehog. By removing engrailed in clones we show that A and P cells also differ in affinity from each other, in a manner that appears independent of Hedgehog. Within the P compartment we found some evidence for a U-shaped gradient of affinity, but this cannot be due to Hedgehog which does not act in the P compartment.