-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default when order is not specifiied is not the ordering of the factors #721
Comments
git bisect script (for use with bisectr) that I used to isolate the commit at https://gist.github.com/4281241 |
Nice! It's good to know I'm not the only person who uses bisectr. |
Another aspect of why this can be a problem: the order of bars depends on the order that things appear in the data. Generally this is not the case for ggplot ( library("ggplot2")
library("plyr")
set.seed(1)
df <- data.frame(x = rep(1:3,each = 3),
y = runif(9),
cat = factor(rep(letters[1:3],times = 3)))
df2 <- arrange(df,y)
p <- ggplot(mapping=aes(x, y, fill=cat)) + geom_bar(stat="identity")
p %+% df
p %+% df2 In general, shouldn't plots be invariant to permutations of rows of the data? Or is it going to a model where the ordering of the data in the data.frame carries relevant information (thus needing an explicit order aesthetic set when consistent ordering, as opposed to data.frame ordering, is desired)? |
The display of a plot should be invariant to the order of the data frame - anything else is a bug. Unfortunately Winston and I are busy with other projects at the moment, but hopefully we'll be able to allocate a couple of weeks to bug fixing later in the year. |
my issue is most likely related: |
This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette. |
Thank you for share this one!!! Works very well!!!! |
Summary
When the order aesthetic is not specified, stacked bar plots are not stacked in the order of the factors which differentiate them (say, fill). This was the case in 0.8.9, but has not been in 0.9.0 onward. I believe it should be the case again.
Example code
In this, the bars are stacked with "a" on the bottom. The expected behavior can be achieved with
However, in the absence of a defined order, the order of the factor levels should be used.
The commit which changed this behavior is e229155
The text was updated successfully, but these errors were encountered: