You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suspect I have found a bug in geom_boxplot() when trying to set the color of the box to be a computed variable. ie.
> library(ggplot2)
>#Horizontal boxes with fill doesn't work with computed variables > ggplot(iris)+ geom_boxplot(aes(y=Species,x=Petal.Width,fill=..middle..))
Errorin FUN(X[[i]], ...) :object'middle'notfound> ggplot(iris)+ geom_boxplot(aes(y=Species,x=Petal.Width,fill=..lower..))
Errorin FUN(X[[i]], ...) :object'lower'notfound>
Other related variants on this theme seem to work ok
library(ggplot2)
#Vertical boxes with fill works with computed variables
ggplot(iris)+
geom_boxplot(aes(x=Species,y=Petal.Width,fill=..middle..))
#Horizontal boxes without fill works
ggplot(iris)+
geom_boxplot(aes(y=Species,x=Petal.Width))
#Horizontal boxes with categorical variables works
ggplot(iris)+
geom_boxplot(aes(y=Species,x=Petal.Width,fill=Species))
Running ggplot Version: 3.3.2.9000 on Windows, built from the master branch on Github 2020-07-09 16:14:23 UTC
Thanks. This seems a documentation problem. You need x prefix for some of the computed variables if you draw geom_boxplot() horizontally (note that the latest recommended way to refer to computed variables is after_stat(var) instead of ..var..):
I created a quick pull request for this (#4128). Honestly, I feel there would be some smarter way to fix this, but I think this is better than nothing for now...
Activity
yutannihilation commentedon Jul 10, 2020
Thanks. This seems a documentation problem. You need
xprefix for some of the computed variables if you drawgeom_boxplot()horizontally (note that the latest recommended way to refer to computed variables isafter_stat(var)instead of..var..):Created on 2020-07-10 by the reprex package (v0.3.0)
clauswilke commentedon Jul 10, 2020
This is the first I hear of this feature, so yes, definitely a documentation problem. :-)
Is this documented anywhere currently? Do we also have
ymiddlefor regular orientation?yutannihilation commentedon Jul 11, 2020
We have
middle(andlowerandupper) for x aesthetics, which feels a bit tricky.Created on 2020-07-11 by the reprex package (v0.3.0)
yutannihilation commentedon Jul 11, 2020
I created a quick pull request for this (#4128). Honestly, I feel there would be some smarter way to fix this, but I think this is better than nothing for now...