在多图中更改模型颜色 (ggplot2)
Change model colors in multiplot (ggplot2)
我正在使用 coefplot
包中的 multiplot
函数,它使用 ggplot2
作为基础。我正在绘制多个模型,但不知道如何更改每个模型的颜色。例如:
require(coefplot)
data(diamonds)
model1 <- lm(price ~ carat + cut, data=diamonds)
model2 <- lm(price ~ carat + cut + color, data=diamonds)
multiplot(model1, model2)
# multiplot(model1, model2, colors = c("blue", "red")) # Doesn't Work
对此有什么想法吗?
您可以尝试添加scale_color
multiplot(model1, model2)+scale_color_manual(values=c("red","blue"))
如果是ggplot基函数,则尝试使用ggplot settigns
我正在使用 coefplot
包中的 multiplot
函数,它使用 ggplot2
作为基础。我正在绘制多个模型,但不知道如何更改每个模型的颜色。例如:
require(coefplot)
data(diamonds)
model1 <- lm(price ~ carat + cut, data=diamonds)
model2 <- lm(price ~ carat + cut + color, data=diamonds)
multiplot(model1, model2)
# multiplot(model1, model2, colors = c("blue", "red")) # Doesn't Work
对此有什么想法吗?
您可以尝试添加scale_color
multiplot(model1, model2)+scale_color_manual(values=c("red","blue"))
如果是ggplot基函数,则尝试使用ggplot settigns