Tourism in Mexico has suffered in recent years with economic troubles and cartel violence discouraging people from visiting the famed Mexican coastline or inland cultural destinations.

Violence in Mexico has fallen and more people, especially Americans, again are visiting the country, spending their valuable tourist dollars. More tourists visited Mexico during the first six months of 2014 than any six month period in the country's recorded history, NBC News reported.

More than 14 million tourists came into the country between January and June, up 20 percent from 2013, according Mexico's Tourism Department.

Tourism first fell off in 2009, as cartel violence became prominent in the country and especially in the national consciousness due to heavy media coverage. The H1N1 strain of the flu also swept the country in 2009, keeping more tourists away.

The next three years all saw a dwindling number of tourists, as cartel violence ravaged parts of the country. It wasn't until last year that tourism numbers returned to their 2008 levels.

A $43 million advertising campaign paid for by Mexico has been credited for bringing back some of the tourists, but a change in media coverage of the violence may have had more to do with the record number of foreigners.

Mexican President Enrique Pena Nieto has made an effort to speak less about the cartel violence publicly, instead focusing on his initiatives to improve the country.

According to a Mexican media monitoring group, local reporting on cartel violence decreased by 50 percent in the first three months of Pena Nieto's term, which began in December 2012.

Marc Murphy, the head of tourism for hotels on the upscale Pacific coast's Riviera Nayarit, says the change in Mexico's violent image has been the biggest factor in bringing tourists back to the beaches.

"The perception of security in Mexico has an enormous effect on tourism. When there were stories of drug violence and cartels every day it stopped some people [from] coming to the resorts, even though they were never much affected by that violence," Murphy said.

"When the president talks less about drugs and violence, the national newspapers write less about it and so the international media report less on it. Perception becomes reality."