A magenta filter will pass both red and blue while blocking green, and a cyan filter will pass through green and blue while blocking red. When light passes through a diffraction grating some is bent to the side. Each position in the spectrum corresponds to a wavelength of light. So each color in the spectrum is a human perception of a single wavelength of light. Transparent plastic filters absorb a wide range of frequencies of light and allow other frequencies to pass through.
Yellow filters absorb blue and allow green and red to pass through.
Human eyes perceive the resulting sum of green and red as the color yellow. The energy of the light absorbed by the filter, warms the filter. The spectrum of light tells us what elements the light sources are made of and also what absorbing elements there are between the light source and us. Dark lines appear in the spectrum of sunlight due to light absorb by atoms in the outer atmosphere of the sun. Replace the slit with a strip of manila folder, an anti slit, observe the resulting colors.