Photo: Universal Pictures and Warner Bros.

A pair of R-rated movies ruled the roost this past weekend. Both films — Steven Soderbergh’s Magic Mike and Seth McFarlane’s Ted — wildly outperformed expectations, with Mike grossing an astonishing near $40 million, while Ted opened to a robust $56 million. At first blush, the reason seemed to be simple: gender. Since each film skewed heavily toward either men (Ted) or women (Mike), the obvious conclusion was that the box office had provided something for both sexes, and everybody won. Simple, right?

Not quite. In fact, the real secret to both films outsize success is actually geography, not gender.

This is not to say that Mike didn’t have massive appeal with women. Indeed, as Warner Bros. marketing chief Sue Kroll tells Vulture, three quarters of the Mike audience were ladies, and nearly two thirds of them came in groups of three or more. But the simple fact is that the film’s success was really attributable to a surprisingly huge overachievement in red states.

“Magic Mike did a ton of business in the Midwest and the South,” explained one awestruck distribution capo at a rival studio who shared Rentrak data, reported by every movie theater across the nation, with Vulture.

Studios know how much any given city usually contributes to a film’s ticket sales: Dallas is 2.62 percent; Tampa, about 1.2 percent; L.A., about 7.5 percent, and so on. This weekend’s data shows that in traditionally conservative, midsize cities, Mike effected double-digit spikes over the average percentage of movie tickets typically sold in those areas. (If a movie’s ticket sales across the U.S. on any given weekend equals 100 percent, each city usually sells about the same percentage of that total number.) For example, Indianapolis and Charlotte saw jumps of around 25 percent, while Orlando, St. Louis, and Nashville all saw leaps of over 30 percent. In Tampa, where the film is set, Mike aroused a 42 percent increase, while Kansas City saw a whopping increase of almost 75 percent over the usual amount of tickets sold.

“Probably not the places you’d have expected it to be doing business,” said this distribution head.

This surge of interest in red states more than made up for a lack of ardor from the blues, where Mike was found mostly wanting: New York City accounted for only 4.7 percent of Mike grosses, almost 30 percent less than what’s usually expected, while Los Angeles accounted for only 6.4 percent of Mike tickets, or almost 15 percent less than would be usually be expected.

Meanwhile, Ted scored by overindexing in blue states and underperforming in red ones — which, given its pokes at feminine white trash nomenclature, should probably come as no surprise.

In Chicago and New York, Ted overshot the usual percentage of tickets sold by over a third; in Las Vegas, by more than 40 percent, and in Boston, where the film is set, by over 70 percent.

Geography aside, there are two more interesting lessons for Hollywood from the success of these two films, says Russell Schwartz, formerly head of marketing at both New Line Cinema and USA Films, and now a consultant to several Hollywood studios.

“They are both original movies with original concepts. That they’re not well-trod studio remakes has as much to do with this [success] as anything.”

Schwartz also adds a third caveat to both Ted and Mike: Despite being raunchy R-rated comedies with supposedly limited audiences, they turned out to be huge financial successes. “That just shows you the market can expand,” says Schwartz, “And that not every thing has to be PG-13 because the studios are so scared of the R.”

In lesser hands than Steven Soderbergh or Seth McFarlane’s, Schwartz says that both Magic Mike and Ted probably could have been forced into becoming PG-13 movies. But instead, each film “had two strong people dictating the director’s cut,” and that in the case of Mike, with its puny $7 million budget, “probably no one was even looking” at what Soderbergh was turning in.

While that’s unlikely, it still points in an excellent direction for how to improve Hollywood’s filmmaking: Sometimes, it’s worth staying loose.