The interaction of nanoparticles with light (photon) is depend upon their environment (refractive index etc.), size or physical dimension. When Oscillating electric fields of a light is propagating near a colloidal nanoparticle they interact with the free electrons and causing the collectively oscillation of free electron same with the frequency of visible light. This resonant oscillation is called surface plasmon. If the any physical parameter as already mentioned is changed the interaction of light with nanoparticles is changed. Hence they showed different colour.
Article Localized Surface Plasmon Resonance as a Biosensing Platform...
See section 1.1.2 for more details (Figure 2). You will also find specific references regarding dependence on shape and/or size.
You can see from Equation 1 that the extinction is linked to the areal density, radius and aspect ratio - all physical properties of the nanostructures.