Home > Back-end >  Change label background to match graph background
Change label background to match graph background

Time:01-05

I have been trying to match the label for my line/point colors to match aesthetically with my graph.

`

ggplot(data = Food, aes(x = X, y = X2022))  
  geom_point(aes(color = "Food"))  
  geom_smooth(aes(x = as.numeric(X), color = "Food"))  
  geom_point(data = Gasoline, aes(x = Year, y = X2022, color = "Gasoline"))  
  geom_smooth(data = Gasoline, aes(x = as.numeric(Year), y = X2022, color = "Gasoline"), se = FALSE)  
  geom_point(data = Energy, aes(x = X, y = X2022, color = "Energy"))  
  geom_smooth(data = Energy, aes(x = as.numeric(X), y = X2022, color = "Energy"), se = FALSE)  
  ylim(0, 450)  
  xlab("Months")  
  ylab("Consumer Price Index")

`

Image output

I tried to use the fill = "white" or fill = "Food" in various parts of the aes() function. I have also tried downloading themes to change it overall, but it doesn't matter what I do. The labels stay a different color no matter what I have tried to change.

Thank you for your help.

CodePudding user response:

Nevermind,

I restarted rstudio, and reloaded the packages. It seems that I was too busy messing around with packages and themes, that I accidently overlapped some. When I reloaded it with only ggplot2 it was fixed.

  • Related