On a steam locomotive, the ashpan sits beneath the firebox, under the grates, to catch the ash that falls from the firebed as one of the wastes of combustion of coal or wood. Oil-fired locomotives do not generally have an ashpan, and its absence is one good indicator that a locomotive is or was an oil burner.
The size of the ashpan is one of the most important limiting factors on the length of run possible with a steam locomotive before it needs minimal servicing, since hot ash and cinders cannot just be dumped anywhere. When the ashpan is full, the locomotive needs to be run over a specially constructed ashpit where the fires are dropped, the ash discarded, and normally any clinker that has formed in the firebed broken up and raked out, and the condition of the firebox inspected.
Since ash is the solid waste product of the combustion of solid fuel, the purity of the fuel also alters the amount of ash produced. High quality fuel such as, say, welsh steam coal contains very little in the way of ash-forming impurities, while such fuels as lignite contain a lot. A locomotive that is fuelled on such needs to have a much larger ashpan (and probably a much larger grate area, too).
The size of the ashpan is, obviously, limited to the space available beneath the firebox, and this is one reason why certain designs of locomotive are better than others. A locomotive with a trailing truck generally has much more room for an ashpan than one without; one with only a two-wheel trailing truck has more than one with an otherwise more desirable four or even six wheel truck.
Ashpan size is a very restricting factor for today's preserved steam locomotives, since the removal of steam servicing facilities after systems dieselised means that such servicing is way more time and labor consuming than hitherto.