  In this paper we prove a theorem stated by Castelnuovo which bounds the
dimension of linear systems of plane curves in terms of two invariants, one of
which is the genus of the curves in the system. Then we classify linear systems
whose dimension belongs to certain intervals which naturally arise from
Castelnuovo's theorem. Finally we make an application to the following moduli
problem: what is the maximum number of moduli of curves of geometric genus $g$
varying in a linear system on a surface? It turns out that, for $g\ge 22$, the
answer is $2g+1$, and it is attained by trigonal canonical curves varying on a
balanced rational normal scroll.
