-
Notifications
You must be signed in to change notification settings - Fork 2.1k
stat_summary_bin
strange behavior when combined with scale_y_*
#2880
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
Comments
This issue seems the same as #2804 (comment). You can restore the transformation (e.g. library(ggplot2)
ggplot(mtcars) +
aes(x = disp, y = mpg) +
stat_summary_bin(fun.y = function(x) log10(sum(10^x)), binwidth = 2.5,
geom = "line", size = 1) +
scale_y_log10() Created on 2018-09-05 by the reprex package (v0.2.0). |
Thanks for the explanation @yutannihilation. The workaround makes sense and after reading that issue I understand that changing this behavior would be a big undertaking. I think a warning or explanation in the documentation for It's nice to be able to do this operation with |
Ah, sorry, I was wrong! During search for the document about this, I found we can use # Transforming the scale means the data are transformed
# first, after which statistics are computed:
p1 <- m2 + scale_y_log10()
# Transforming the coordinate system occurs after the
# statistic has been computed. This means we're calculating the summary on the raw data
# and stretching the geoms onto the log scale. Compare the widths of the
# standard errors.
p2 <- m2 + coord_trans(y="log10") So, in this case you could write like library(ggplot2)
p <- ggplot(mtcars) +
aes(x = disp, y = mpg) +
stat_summary_bin(fun.y = sum, binwidth = 2.5,
geom = "line", size = 1)
p1 <- p + scale_y_log10()
p2 <- p + coord_trans(y = "log10")
egg::ggarrange(p1, p2) Created on 2018-09-05 by the reprex package (v0.2.0). |
IIUC, the summary of #2804 is:
|
Oh wow, it is in the docs after all... but hidden in an example. I do think this nuance regarding the Thanks for pointing out these two options for resolving the issue. |
Agreed that there should be a section for this in the doc of But..., |
I think just a note about using
|
Closing this issue for the reason above. |
Attempting to do a binned summation of data via
fun.y
withstat_summary_bin
and represent as a line. I get strange y-axis labels when combining with ascale_y_*
aesthetic. It looks like a bug to me, but perhaps I misunderstand how to usestat_summary_bin
.Created on 2018-09-04 by the reprex package (v0.2.0).
The text was updated successfully, but these errors were encountered: