Afterimages occur because photochemical activity in the retina continues even when the eyes are no longer experiencing the original stimulus.
A common physiological afterimage is the dim area that seems to float before one's eyes after briefly looking into a light source, such as a camera flash.
[3] Normally, any image is moved over the retina by small eye movements known as microsaccades before much adaptation can occur.
They are accompanied by neural adaptation in the occipital lobe of the brain that function similar to color balance adjustments in photography.
Specifically, afterimages are the complementary hue of the adapting stimulus, and trichromatic theory fails to account for this fact.
Anything resulting in less green is interpreted as its paired primary color, which is magenta (an equal mixture of red and blue).
The cause of positive afterimages is not well known, but possibly reflects persisting activity in the brain when the retinal photoreceptor cells continue to send neural impulses to the occipital lobe.