Paul Thomas Anderson is back with coming-of-age romance Licorice Pizza, one of the most acclaimed films of his career. Set in the 1970s, the movie charts the love story of teenage actor Gary Valentine and twentysomething photographer’s assistant Alana Kane. As always, Anderson cast the perfect actors to play his lead roles: Cooper Hoffman and Alana Haim, respectively.

RELATED: Paul Thomas Anderson's 5 Most Lovable Characters (& 5 That Fans Love To Hate)

Almost every role in Anderson’s movies has been perfectly cast, from Boogie Nights’ Dirk Diggler to The Master’s Freddie Quell, but those actors weren’t always the first choice for the part.

Dirk Diggler In Boogie Nights

Perfectly Cast: Mark Wahlberg

Mark Wahlberg as Dirk Diggler in a closeup in Boogie Nights

Dirk Diggler, the central protagonist in Boogie Nights, is a bright-eyed young hotshot cutting his teeth in the adult film industry. Mark Wahlberg did a fantastic job of playing Dirk as a fish out of water amidst the misleading glitz and glamor of show business.

This was the movie in which Wahlberg proved his chops as a dramatic actor, as all popstar-turned-actors have to do when they first make the transition between mediums.

Almost Cast: Leonardo DiCaprio

Jack kisses Rose's hand in Titanic

According to CinemaBlend, the role of Dirk Diggler was offered to a young Leonardo DiCaprio, but he turned it down in favor of the part that made his career: Jack in James Cameron’s Titanic.

There have since been rumors of an intense feud between Wahlberg and DiCaprio over the role of Dirk, but Anderson elaborated, “That’s [an] urban legend. There was no Leo vs. Mark because Leo decided not to do the film.”

Dean Trumbell In Punch-Drunk Love

Perfectly Cast: Philip Seymour Hoffman

Philip Seymour Hoffman yelling on the phone in Punch Drunk Love

The greatest performance in Anderson’s refreshingly low-key romance Punch-Drunk Love is, of course, Adam Sandler’s surprisingly nuanced turn in the lead role of Barry Egan.

RELATED: How Punch-Drunk Love Reinvents Romance Tropes (& Why It's Still A Great Love Story)

But Philip Seymour Hoffman offers a hilarious counterpoint to Sandler as the hotheaded Dean Trumbell, better known as “The Mattress Man.” Sandler and Hoffman made for well-matched scene partners, especially in their climactic screaming match.

Almost Cast: Sean Penn

Sean Penn in a jail cell in Dead Man Walking

Anderson has finally gotten to work with Sean Penn on Licorice Pizza, in which he plays an aging movie star based on William Holden. According to Variety, the director has been trying to work with Penn for a while.

Anderson explained, “I’ve been asking Sean Penn to be in movies for as long as I’ve been doing this... I talked to him around the time of Punch-Drunk Love... and he was going to be the foil against Adam Sandler, but that didn’t work.”

Eli Sunday In There Will Be Blood

Perfectly Cast: Paul Dano

Eli looking serious in There Will Be Blood

Daniel Day-Lewis undoubtedly gives the most memorable performance in There Will Be Blood with his Oscar-winning turn as oil tycoon Daniel Plainview. But Paul Dano proves to be a great foil for Day-Lewis in some of the film’s most intense scenes.

The actor does an incredible job with dual roles, seamlessly playing twins Paul and Eli Sunday as entirely distinctive characters.

Almost Cast: Kel O’Neill

Kel O'Neill at a red carpet event

According to IndieWire, Paul and Eli weren’t originally written as identical twins; they were nonidentical brothers. Dano was originally only cast as Paul and Kel O’Neill was cast as Eli.

RELATED: Why There Will Be Blood Is Paul Thomas Anderson's Masterpiece

However, O’Neill was fired shortly into production and the characters were rewritten as twins with Dano playing both parts. O’Neill explained, “An actor should, with every ounce of their humanity, be attempting to give the director what he or she wants. And I recall going in and out on whether I could really do that.”

Earl Partridge In Magnolia

Perfectly Cast: Jason Robards

Earl Partridge on his deathbed in Magnolia

As one of the few recipients of the Triple Crown of Acting – with two Academy Awards, a Tony, and an Emmy – it’s safe to say that Jason Robards is a true legend of stage and screen.

Earl Partridge in Anderson’s sprawling epic Magnolia ended up being the actor’s final film role. Robards played the part with genuine pathos opposite a delightfully eccentric Tom Cruise as his estranged son, Frank T.J. Mackey.

Almost Cast: George C. Scott

George C. Scott doing a salute in Patton

According to Mental Floss, while the role of Earl was always written with Robards in mind, the actor initially had to turn down the part due to a serious staph infection.

So, Anderson began searching for another actor and offered the part to George C. Scott, who threw his script across the room and said, “This is the worst f**king thing I’ve ever read. The language is terrible.”

Freddie Quell In The Master

Perfectly Cast: Joaquin Phoenix

Joaquin Phoenix sitting in front of a painting in The Master

Anderson followed up the epic scope of There Will Be Blood with the equally epic scope of The Master, a thinly veiled critique of Scientology in which a charming cult leader takes advantage of an aimless World War II veteran named Freddie Quell.

RELATED: 10 Behind-The-Scenes Facts About The Master

Joaquin Phoenix’s captivating, heartbreaking turn as Freddie was the first in a long line of performances as disturbed loners – followed by You Were Never Really Here and Joker.

Almost Cast: Jeremy Renner

Clint sitting in a cafe smiling in Hawkeye.

According to IndieWire, Jeremy Renner was originally in talks with Anderson to take the role of Freddie in The Master. However, the initial financing fell through and Anderson’s development of the film stalled.

By the time they started up again, Renner had become an Avenger and couldn’t fit the shoot into his schedule. Anderson said of the what-if casting, “You know, in the life of a film – every one of them is different – but what ends up happening is usually the right thing.”

NEXT: 5 Roles In David Fincher Movies That Were Perfectly Cast (& Who Almost Played Them)