No path with stat="summary" #732

Closed
low-decarie opened this Issue Dec 5, 2012 · 11 comments

7 participants

@low-decarie

Thank you for all the good work.

This comes from a discussion on google group:
https://groups.google.com/forum/?fromgroups=#!search/With$20stat=%22summary%22,$20fun.y=%22mean%22$20get$20%22Each$20group$20consist$20of$20only$20one$20observation%22/ggplot2/ECI59jsdOYc/CCm1MOxXnhEJ

Examples:

d <- qplot(cyl, mpg, data=mtcars)
d + geom_line(stat="summary", fun.y="mean")

or

stat_sum_single <- function(fun, geom="point", ...) {
  stat_summary(fun.y=fun, colour="red", geom=geom, size = 3, ...)
}

d + stat_sum_single(mean, geom="line", aes(group=as.character(cyl)))

or

ggplot(mtcars, aes(x=cyl, y=mpg)) +
  geom_point() +
  stat_summary(fun.y=mean, geom="line", aes(group=factor(cyl)))

or
...

all give
"geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?"

with no path traced on plot

@low-decarie

same as #739 ?

@rasmusab

Also, this error seems to have propagated to the documentation (for example, plot nbr 6):
http://docs.ggplot2.org/current/stat_summary.html

@bbolker

bump ... ? any thoughts from developers about whether this is easy or hard to fix, or work around?

@mortenlindow

Bump...

breaks lots of plots. Does anyone know which version to one should revert to in order to get the desired behaviour?

@HarlanH

This is a pretty frustrating regression. Would love to see a fix, or at least a comment on it, soon...

@wch
Collaborator

Sorry, we've been occupied with other things recently. We'll probably have a 0.9.3.1 release with a fix for this.

@kohske
Collaborator

I write an temporary patch that can draw the line with stat_summary.
I write it for my own use, but as this change may introduce huge problem (even for me...), I put it on gist.

Here is a simple usage:

library(devtools)
source_gist("https://gist.github.com/4578531")

library(ggplot2)

d <- qplot(cyl, mpg, data=mtcars)
d <- d + aes(colour = factor(vs)) + stat_summary(fun.y = mean, geom="line")
d

Note that you need to install devtools.

@hadley and @wch Please let me know if I should not share this on gist.

@wch
Collaborator

@kohske, so this basically changes StatSummary back to the previous 0.9.2.1 version? I think that should be OK as a temporary fix.

@kohske
Collaborator

@wch yes. It is same as 0.9.2.1.

@low-decarie

@kohske, thanks a lot. This really saved my plots!

@wch wch added a commit to wch/ggplot2 that referenced this issue Feb 27, 2013
@wch wch Revert stat_summary grouping. Fixes #739 and #732 525bcca
@wch wch added a commit to wch/ggplot2 that referenced this issue Mar 1, 2013
@wch wch Revert stat_summary grouping. Fixes #739 and #732 deb4c50
@wch
Collaborator
wch commented Mar 1, 2013

Fixed by #770.

@wch wch closed this Mar 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment