I dare you to ask any writer, "Have you ever had trouble sleeping because of a story?" I'm willing to bet that at least 99% of them will respond with an affirmative "Abso-damn-lutely!"
I've had many nights where I was trying my best to get to sleep, but the story in the back of my mind refused to let my brain shut off. When that happens, I HAVE to get up and write down everything that's coming into my mind. Only once it's down on paper will I be able to sleep. I've been up until ungodly hours in the morning because of a story that's working itself out in my mind. It's something we writers learn to live with.
I'm certain a lot of artists struggle with the same issue. I know my father, a musician, has gotten up in the middle of the night to write down lyrics or melody that refused to leave him alone. I'm certain the other artists (graphic designers, sketch artists, cover artists, etc.) in my family have also wrestled with a creative idea well into the wee hours of the night.
A study from an Israeli University found that visually creative people (painters, artists, etc.) tend to sleep less at night. The quality of their sleep is also worse. Their disturbed sleep habits can lead to difficulties functioning during the day.
But for verbally creative people (like writers), we tend to sleep more hours, but we get to sleep later and wake up later. I know a lot of my writer friends like to get their work done late at night or in the wee hours of the morning. (Having a day job and a family also necessitates this habit.) Instead of getting up early in the morning to write, it's easier to stay up late to get in the writing time, then sleep in a few hours later.
Why is there a difference between the two? The study didn't quite come up with a clear, well-defined reason why visual and verbally creative people have different sleep patterns, but it suggested that it came down to the neurological patterns of connectivity that control creativity. Visually creative people tend to be more alert all day and night, leading to sleep disturbances. Verbally creative people tend to be more creative while they are awake, but their brains are better-able to shut off at night. The cerebral mechanisms that control the two types of creativity (verbal and visual) are different, and thus affect the artist differently.
Either way, if you intend to be an artist of any sort (painter, sculptor, videographer, photographer, or writer), prepare for a few (or many) sleepless nights. The curse of the artist is that our brains never fully stop creating and making creative associations. Learning how to harness and channel the creative power of our brains is the closest we get to finding peace when it's time to sleep. But sometimes, there's nothing to do but accept we're not going to get a full night of sleep and make use of our creativity. It's definitely more of a gift than a curse!