Colour line on scatter plot - R

Lois Fleming

I have created a scatter plot for CO2 emissions for Argentina and Brazil. How would i make them different colours? at the moment it's all green. Thanks Lois

df%>%
  dplyr:: filter(Country %in% c("Argentina", "Brazil")) %>%   
  filter(Year<=2019 & Year>=1950) %>%   
  ggplot(aes(x = Year, y = CO2_annual_tonnes)) + 
    geom_point(na.rm =TRUE, shape=20, size=2, colour="green") + 
    labs (x = "Year", y = "CO2Emmissions (tonnes)")
TarJae

Try this:

library(ggplot2)
library(dplyr)
df%>% 
  dplyr:: filter(Country %in% c("Argentina", "Brazil")) %>%    
  filter(Year<=2019 & Year>=1950) %>%    
  ggplot(aes(x = Year, y = CO2_annual_tonnes, colour=factor(country))) + 
  geom_point(na.rm =TRUE, shape=20, size=2) + 
  labs (x = "Year", y = "CO2Emmissions (tonnes)")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related