Ellipsoidal harmonics are presented as a basis function set for the design of shim coils for magnetic resonance imaging (MRI) or spectroscopy. MR shim coils may be either superconductive or resistive. Ellipsoidal harmonics form an orthogonal set over an ellipsoid and hence are appropriate in circumstances where the imaging or spectroscopic region of a magnet more closely conforms to an ellipsoid rather than a sphere. This is often the case in practice. The Cartesian form of ellipsoidal harmonics is discussed. A method for the design of streamline coil designs is detailed and patterns for third-order ellipsoidal (Lame) shims wound on a cylindrical surface are presented.