Spin densities in 4f and 3d magnetic systems