The presidential campaign season has been very good for Barack Obama.

Since the fall of 2015, the president’s favorability rating and job approval have increased by three and five percentage points, respectively, in polling averages.  A majority of Americans consistently rate Obama favorably for the first time since his second term began.

The president joked about his growing popularity a few months ago at the White House correspondents’ dinner, saying: “Even my aides can’t explain the rising poll numbers — what has changed, nobody can figure it out.” An image of Ted Cruz and Donald Trump then appeared on the projection screen beside the president. The obvious implication of the joke was that the president’s unpopular opponents — Trump and Cruz — were making him look good in comparison.

But Trump and Cruz aren’t the only ones who might be making Barack Obama look good.  The president’s Democratic successor, Hillary Clinton, is also very unpopular.  So much so, in fact, that she would be the least popular major party nominee in modern times if it weren’t for Donald Trump’s record-high negatives.

Clinton and Trump’s flawed candidacies are even making some nostalgic for Obama’s presidency while he’s still in office. David Brooks, for example, wrote a piece during the primaries entitled “I Miss Barack Obama,” in which he compared the president most favorably with the presumptive Democratic and Republican nominees. Or as he put it, “Obama radiates an ethos of integrity, humanity, good manners and elegance that I’m beginning to miss, and that I suspect we will all miss a bit, regardless of who replaces him.”

If such campaign-induced nostalgia is indeed fueling Obama’s surging poll numbers, then Americans who have an unfavorable opinion of both Clinton and Trump — around 25 percent of adults — should increasingly support the president.  That’s exactly what the two graphs below show.

First, here is the trend in Obama’s favorability over the past year in YouGov/Economist surveys for two different groups: Those who rate both Clinton and Trump unfavorably and those who don’t.

Obama’s rising popularity has been entirely concentrated among those with negative opinions of both Trump and Clinton. In the past year, the president’s favorability rating has increased by 20 percentage points among this group.  Meanwhile, his favorability rating has actually declined among Americans with a favorable opinion of Trump and/or Clinton.

Rand Corp.’s Presidential Election Panel Survey (PEPS) provides further insight into Obama’s rising popularity.  The PEPS data track changes in the president’s favorability rating among the same 2,679 individuals who were interviewed in December 2015 and March 2016. Using those data, I estimated the influence of views of Clinton and Trump on changes in Obama’s popularity after accounting for other relevant factors, such as partisanship, ideology and demographics.  The graph below presents the results.

Again, Obama’s rising popularity is concentrated among those with unfavorable opinions of Hilary Clinton and Donald Trump. Obama’s favorability rating increased by about 12 percentage points from December 2015 to March 2016 among PEPS respondents who had a very negative opinion of both candidates.  His popularity, however, did not change significantly among those with more positive opinions of Clinton and Trump.

It appears, then, that Obama can thank both Clinton and Trump for his growing popularity. Dissatisfaction with the leading presidential candidates seems to have made Obama more popular than he has been in years.

Michael Tesler is associate professor of political science at UC Irvine and author of Post-Racial or Most-Racial? Race and Politics in the Obama Era.