Reputation: 31
I would like to change the colour of the confidence bands of two data sets in a common scatter plot. The colour of the data set have been already changed from the default to costumized. Now, the colours of the confidence bands shall be changed to blue and green as well.
The data set looks like this.
I would appreciate your suggestions. Thanks!
Stage OAL TL Blasto 57 95 Blasto 61 85 ... Oozoid 7 9 Oozoid 22 29 ...
library("ggplot2")
library("reshape2")
library("tidyverse")
p<-ggplot(ThomTOAL,aes(x=TL,y=OAL,colour=Stage))+
geom_point(alpha=0.4,size=2.5)+
geom_smooth(method=lm)+
labs(x="\nTL (mm)",y="OAL (mm)\n")+
scale_color_manual(values=c('blue','green'))+
theme(axis.title.x=element_text(size=18),
axis.text.x=element_text(size=14,colour="black"),
axis.title.y=element_text(size=18),
axis.text.y=element_text(size=14,colour="black"),
axis.ticks=element_blank(),
legend.position=c(0.18,0.87),
legend.text=element_text(colour="black",size=14),
legend.title=element_blank())
p
Upvotes: 1
Views: 766
Reputation: 4863
If I understood you correctly, you're looking for color =
and fill =
inside the geom_smooth()
argument/method.
I used mtcars
dataset for reproducibility.
library(tidyverse)
mtcars %>%
ggplot(aes(mpg, qsec, group = am, color = am)) +
geom_point() +
geom_smooth(method = "lm",
color = "blue",
fill = "green")
You can find here more information about it.
Upvotes: 1