Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

facet reordering with new layer/data #543

Closed
baptiste opened this Issue May 7, 2012 · 2 comments

Comments

Projects
None yet
4 participants
Contributor

baptiste commented May 7, 2012

The facet order is broken when adding a new layer with new data.

library(ggplot2)
set.seed(123)

d <- data.frame(x=1:15, y=rnorm(15), f=factor(rep(letters[1:3],
each=5), levels=letters[1:3]))

## all fine, facets are a, b, c
( p <- ggplot(d, aes(x, y)) + facet_grid(f~.)+
 geom_path()  )

d2 <- data.frame(x=2, y=2, f="b",
                           stringsAsFactors=FALSE) # to be sure

## now the facets are in a different (wrong) order!
p +  geom_blank(data=d2)
Collaborator

kohske commented May 18, 2012

This will be fixed at:

base <- unique(ldply(values[has_all]))    

in layout_base of facet-layout.r.

But things are complicated.

Owner

hadley commented Jun 7, 2012

I think this should use the same algorithm as discrete scales do when adding new values.

@wch wch was assigned Jul 4, 2012

@wch wch added a commit to wch/ggplot2 that referenced this issue Jul 8, 2012

@wch wch Correct order of facets when adding layers. Fixes #543 27f727e

@wch wch closed this in 31df5ac Jul 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment