I’m completely new to R and I would like to create a plot using ggplot2. My aim is to have a scatter plot with x=CAO and Y=F, I also need to have the data points to have a specific color depending on their name in column RN. I could do it manually but my actual dataset has thousand of entries…
RN CAO F
1 HAWAIITE 52.7 4.64
2 HAWAIITE 53.9 3.75
3 MUGEARITE 53.8 3.59
4 MUGEARITE 53.4 3.45
5 BENMOREITE 53.5 4.2
6 BENMOREITE 53.3 2.00
7 TRACHYTE 53.2 3.68
8 HARZBURGITE, XENOLITH 52.2 4.82
9 WEHLERITE, XENOLITH 51.9 5.51
10 DUNITE, XENOLITH 54.0 4.40
Thank you for your help!
Here is my code now, I get the scatter plot but all points have the same color.
georoc %>%
select(RN,CAO,F)
ggplot(georoc, aes(x = CAO, y = F ,colour = "RN"))+
geom_point(size = 4, alpha = 0.8, stroke = 1, aes(color ="RN")) +
theme(legend.position= "none")
labs(title = "CAO vs F",
x = "CAO", y = "F")
Clementine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.