Hello I am trying to get a plot that looks like the attached picture however I would like to change the colours so that they form a gradient ( the three levels of the plotted variables are actually three points in a continuum). So for example it would be best if the red line is orange, the blue line is going towards yellow and the red is yellow
The code I used for these plots is the following:
p13 <-plot(pred,ci.style="ribbon",alpha = 0.2) + theme_clean() +
geom_line(size=0.1) + labs(x="Time", y="Task", title = "Plot Title",
subtitle = "Subtitle") +
theme_clean(base_size = 10) + theme(
plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank()) + theme(legend.position = "bottom")
par(mar=c(5,6,4,1)+.1)
p13
You are using ggeffects, makes sense to include it in your question. When you call plot()
on a ggeffect object, it returns a ggplot object, so you just specify the colors and fill using scale_*_manual, there are a lot of tutorials for example something like this .
And for colors, you can check out the palettes you like, i use a yellow-orange.
Using iris dataset:
library(ggplot2)
library(ggeffects)
library(RColorBrewer)
iris$grp = sample(c("A","B"),nrow(iris),replace=TRUE)
fit = lm(Petal.Width ~ Petal.Length+Species+grp,data=iris)
pred = ggpredict(fit,terms=c("Petal.Length","Species","grp"))
Then plot:
plot(pred,ci.style="ribbon",alpha = 0.2)+
scale_color_manual(values=brewer.pal(3,"YlOrRd"))+
scale_fill_manual(values=brewer.pal(3,"YlOrRd"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.