Hi Alain,
I think your issue lies with geom_smooth(). From the help page:
"smoothing method (function) to use, eg. lm, glm, gam, loess, rlm. For
datasets with n < 1000 default is loess. For datasets with 1000 or
more observations defaults to gam, see gam for more details."
I was going to say that the subset of tmp to only period 1 was less
than 1000. However it is 3000:
nrow(tmp[tmp$period=="1",])
So I am a bit confused there. Nevertheless, ggplot2 does appear to
choosing a different smoothing method for the two calls. If you set it
manually with say LOESS they then appear identical. So if you really
want to forge ahead, simply choosing a smoothing method and use that
here. If you want to understand exactly what is going on, wait for
other more knowledgeable wizaRds to chime in here. For the example
below I've made use of grid.arrange to facilitate comparison:
# plot with the three periods
AllLevelsPlt <- ggplot(tmp,aes(x=x,y=y,col=color,linetype=ligne))+
geom_smooth(method="loess", se=FALSE)+
scale_colour_manual(values=c("black","blue","yellow"))+
guides(linetype=FALSE,col=FALSE)+
facet_grid(period~.)
#plot with only the first period
OnlyPeriod1Plt <-
ggplot(tmp[tmp$period=="1",],aes(x=x,y=y,col=color,linetype=ligne))+
geom_smooth(method="loess", se=FALSE)+
scale_colour_manual(values=c("black","blue","yellow"))+
guides(linetype=FALSE,col=FALSE)+
facet_grid(period~.)
## Combine into one plot for comparison
grid.arrange(OnlyPeriod1Plt, AllLevelsPlt, heights=c(1,3))
HTH,
Sam
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
>
https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email
ggp...@googlegroups.com
> To unsubscribe: email
ggplot2+u...@googlegroups.com
> More options:
http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
ggplot2+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.