Roth IRA

Are capital gains part of earned income in order to contribute the full $6000 to my Roth? It says penalty because at my job I only made 4500 but made 1600 in capital gains that I thought would count towards the full contribution. I already contributed and it’s saying I must remove that money. Thanks for the help