0

I am trying to create a bubble chart using R studio, my codes are as follow:

library(ggplot2)

bone$gr = bone$Line

ggplot(bone, aes(x = Year, y = bup, size = Patients, col = gr)) + geom_point() + 
  geom_abline(intercept = -1.433254613, slope = 0.000836604, col = "red") +
  geom_abline(intercept = -2.384481355, slope = 0.001309739, col = "blue")

gr is a group/class variable that divides the dataset into two groups, I want to show the two groups with different colors as this picture shows: enter image description here

Is there any way I can change the color of the two groups?

UseR10085
  • 7,120
  • 3
  • 24
  • 54

0 Answers0