We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
I noticed that geom_smooth behaves like geom_path rather than geom_line. For example,
geom_smooth
geom_path
geom_line
library(ggplot2) ggplot(transform(mtcars, pred.mpg = predict(lm(mpg ~ poly(hp, 2), data = mtcars), interval = "confidence"))) + geom_smooth(aes(x = hp, y = pred.mpg.fit, ymin = pred.mpg.lwr, ymax = pred.mpg.upr), stat = "identity")
produces
Whereas ordering by the x-axis variable produces the desired result:
ggplot(transform(mtcars, pred.mpg = predict(lm(mpg ~ poly(hp, 2), data = mtcars), interval = "confidence"))[order(mtcars$hp), ]) + geom_smooth(aes(x = hp, y = pred.mpg.fit, ymin = pred.mpg.lwr, ymax = pred.mpg.upr), stat = "identity")
I looked at the geom_smooth code, but I don't understand why it behaves this way. It looks like GeomSmooth calls GeomLine, and GeomLine does
GeomSmooth
GeomLine
setup_data = function(data, params) { data[order(data$PANEL, data$group, data$x), ] }
so I would have thought ordering the data myself would make no difference.
The text was updated successfully, but these errors were encountered:
It probably just calls the draw method, not the setup_data() method.
setup_data()
Sorry, something went wrong.
Thanks, I've submitted #2029 to address this.
Order path data in GeomSmooth (#2029)
fa8004e
Fixes #2028
No branches or pull requests
I noticed that
geom_smooth
behaves likegeom_path
rather thangeom_line
. For example,produces

Whereas ordering by the x-axis variable produces the desired result:
I looked at the
geom_smooth
code, but I don't understand why it behaves this way. It looks likeGeomSmooth
callsGeomLine
, andGeomLine
doesso I would have thought ordering the data myself would make no difference.
The text was updated successfully, but these errors were encountered: