I was wondering if it's possible to set a different span parameter for each facet of my ggplot object. I have four sets of related industry data that I would like to compare on a single ggplot object. I would like to modify the span for each geom_smooth()
line to more accurately model my data.
library(ggplot2)
library(reshape2)
a=rnorm(50,0,1)
b=rnorm(50,0,3)
ind=1:100
df=data.frame(ind,sort(a),sort(b))
df1=melt(df, id='ind')
t=ggplot(df1, aes(x=ind,y=value, color=variable))+
geom_smooth(color='black', span=.5)+
geom_point(color='black')+
facet_wrap(~variable,ncol=2)
For instance, is it possible to have a span of .5 for the first facet and a span of .8 for the second facet?
You can filter your data and only provide the filtered subset to each
geom_smooth