I've got two teams and a given value for each team and year for a certain time interval. My data looks like the following:
yearID | teamID | value |
---|---|---|
2020 | 0 | 5 |
2020 | 1 | 7 |
2019 | 0 | 3 |
2019 | 1 | 1 |
I want to plot this with a point for each year and value, distunguishing between teams by color. Additionally I want to draw lines between points grouped by year. I am almost there:
ggplot(hr_by_team_year_sf_la_df, aes(x='yearID', y='HR', group='yearID')) + geom_line() + geom_point()
resulting in the following plot:
Only colors miss for now. I've tried several approaches but none succeeded:
ggplot(hr_by_team_year_sf_la_df, aes(x='yearID', y='HR', group='yearID')) + geom_line() + geom_point(aes(color='teamID'))
ggplot(hr_by_team_year_sf_la_df, aes(x='yearID', y='HR', group='yearID', color='teamID')) + geom_line() + geom_point()
Anyone got an idea how to paint the points depending on the teamId?