r语言 - 更改标签背景以匹配图形背景



我一直在尝试为我的线/点颜色匹配标签,以符合我的图形的美学。

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")

图像输出

我试着用fill = "white"or fill = "Food"在aes()函数的各个部分中。我也试过下载主题来改变它,但不管我做什么。不管我怎么改变,标签的颜色都是不一样的。

谢谢你的帮助。

别介意,

我重新启动了rstudio,并重新加载了包。似乎我太忙于处理包和主题,我不小心重叠了一些。当我用ggplot2重新加载它时,它被修复了。

最新更新