Example data frame:
df <- data.frame(x=rep(1:10,4),y=rnorm(40),Case=rep(c("B","L","BC","R"),each=10))
I can build each time series on my face with:
ggplot(df,aes(x=x,y=y,color=Case)) + geom_line()+facet_wrap(~Case,nr=2,nc=2)
Now suppose that I want to change the order of the facet (starting from the upper left corner and ending at the bottom right in the rows) "L", "B", "R", "BC". The usual suggestion here about SO is to do this . However, if I reorder the levels of the Case factor, the colors of the curves will also change. Is it possible to reorder faces without also changing the order of the colors of the curve? I know this sounds like a weird question. The problem is that my report is incomplete, and in an earlier version of the report, which I already showed to employees and management, there were several or more similar sections (without facet_wrap ):
ggplot(df,aes(x=x,y=y,color=Case)) + geom_line()

In other words, by now people are used to associating “B” with red. If I reorder, “L” will be red, “B” will be green, etc. I already hear complaints ... anyway from this?
r ggplot2 facet-wrap
Deltaiv
source share