High school career
In 2005, Anderson helped lead the Oak Ridge Trojans to the Division II California State Championship. The game was held at ARCO Arena in Sacramento. In the opening round of that playoff series, Anderson's No. 1 ranked team narrowly averted an upset against a John H. Pitman High School team led by Colin Kaepernick, who would later go on to become an NFL San Francisco 49ers quarterback.  In that game, Kaepernick scored 34 points while Anderson scored 50. 
Anderson played two seasons for the California Golden Bears, averaging 18.7 points and 9.0 rebounds in 33.0 minutes per game in 66 career games. As a freshman in 2006–07, he led the Bears in scoring and rebounding, averaging 16.3 points and 8.2 rebounds, and earned Honorable Mention All-Pac-10 honors. He went on to be named Second Team All-America by The Sporting News and earned First Team All-Pac-10 honors as a sophomore in 2007–08. He led the Pac-10 in scoring, averaging 21.1 points (ranked 18th in nation) and ranked third in rebounding, pulling down 9.9 rebounds per game. 
New Jersey Nets (2008–2009)
On June 26, 2008, Anderson was selected with the 21st overall pick in the 2008 NBA draft by the New Jersey Nets. He made his NBA debut on October 29, 2008 against the Washington Wizards. He played in 66 games during his rookie campaign with New Jersey, averaging 7.4 points and 4.7 rebounds in 19.9 minutes per game, as he ranked 10th among all NBA rookies in three-point field-goal percentage (.365 – 69-of-189).
Orlando Magic (2009–2012)
On June 25, 2009, Anderson was traded, along with Vince Carter, to the Orlando Magic in exchange for Rafer Alston, Tony Battie and Courtney Lee.  In 2009–10, he appeared in 63 games with Orlando, averaging 7.7 points and 3.2 rebounds in 14.5 minutes per game. He started in six games during the regular season, and played in a further nine playoff games.
In 2010–11, Anderson played in 64 games (14 starts) with Orlando, averaging 10.6 points and 5.5 rebounds in 22.3 minutes per game. During December 2010, he missed nine games due to a sprained right foot. 
In the lockout-shortened 2011–12 season, Anderson won the NBA Most Improved Player Award after averaging 16.1 points and 7.7 rebounds in 61 games.  He led the NBA in both three-point field goals made and attempted, while ranking seventh in free throw percentage, tied for 27th in three-point field goal percentage, ranking 29th in rebounding and 33rd in scoring.
New Orleans Hornets/Pelicans (2012–2016)
On July 11, 2012, Anderson was acquired by the New Orleans Hornets in a sign-and-trade deal that sent Gustavo Ayón to the Magic.  During his first season for the Hornets in 2012–13, he appeared in 81 games (22 starts) and averaged 16.2 points, 6.4 rebounds and 1.2 assists per game. He finished second in the NBA with a career-high 213 three-point field goals made in 557 attempts (38.2%).  In April 2013, the Hornets changed their name to the Pelicans. 
On December 2, 2013, Anderson scored a career-high 36 points in a 131–128 triple overtime win over the Chicago Bulls.  On January 3, 2014, Anderson suffered a neck injury colliding with Gerald Wallace in the Pelicans' 95–92 win over the Boston Celtics. Anderson, who had to be removed from the court on a stretcher, required neck surgery and was ruled out for the rest of the season in late March.  He managed just 22 games in 2013–14, averaging 19.8 points and 6.5 rebounds per game.
On October 28, 2014, Anderson made his return for the Pelicans in their season-opening game against the Orlando Magic. In 22 minutes of action, he recorded 22 points and 9 rebounds off the bench in a 101–84 win.  On February 22, 2015, he was ruled out for two to four weeks after being diagnosed with an MCL sprain in his right knee.  He returned to action on April 1 and played out the regular season, and appeared in the team's four playoff games.
Anderson continued to be an effective role player off the bench for the Pelicans in 2015–16. On January 15, 2016, he scored a then season-high 32 points and hit six three-pointers in a 109–107 win over the Charlotte Hornets.  On January 23, he scored 23 points and tied a season high with six three-pointers in a 116–99 win over the Milwaukee Bucks. In that game, the Pelicans hit a franchise-best 17 three-pointers.  On January 28, he scored 30 of his career high-tying 36 points in the first half of the Pelicans' 114–105 win over the Sacramento Kings. Starting in just his seventh game of the season, at power forward in place of the injured Anthony Davis, Anderson's 30 first half points set a franchise record.  After being diagnosed with a sports hernia in late March, Anderson missed the team's final 14 games of the season. 
Houston Rockets (2016–present)
On July 9, 2016, Anderson signed with the Houston Rockets.  He made his debut for the Rockets in their season opener on October 26, recording 14 points and six rebounds in a 120–114 loss to the Los Angeles Lakers.  On December 1, he scored a season-high 29 points in a 132–127 double overtime win over the Golden State Warriors.  On December 23, he set a new season high with 31 points in a 115–109 loss to the Memphis Grizzlies. 
NBA career statistics
|GP||Games played||GS||Games started||MPG||Minutes per game|
|FG%||Field goal percentage||3P%||3-point field goal percentage||FT%||Free throw percentage|
|RPG||Rebounds per game||APG||Assists per game||SPG||Steals per game|
|BPG||Blocks per game||PPG||Points per game||Bold||Career high|