As President Obama heads to Mexico, a recent Pew poll found that public opinion of the U.S. in the country is at its highest in years. Check out this chart from Max Fisher at WorldViews:

What happened?

The main driver seems to be immigration policy. After Arizona passed its controversial immigration law in 2010, Mexican opinion of the U.S. plummeted from 62 percent to 44 percent. Since hitting that nadir, it has gone back up, including a 10-point jump in the past year. Last summer, Obama halted deportation for some young immigrants, and this year, Congress has begun work on bipartisan immigration reform.

Obama's personal numbers have also been on the rise. In 2011, 38 percent of Mexicans were confident in his handling of world affairs; that's now at 49 percent. But Mexicans are divided on whether the U.S. is having a good or bad impact on their country's economy, even though 70 percent consider deep economic ties with the U.S. a good thing.

Most Mexicans (61 percent) wouldn't move to the U.S. if they could, but about a third (35 percent) would. (Last year, more Mexicans left the U.S. than entered it for the first time.) One in four know someone who has been deported from the U.S. or detained for immigration reasons.

Obama's three-day trip is meant to focus on trade and security, but immigration will inevitably come up.