-
Notifications
You must be signed in to change notification settings - Fork 633
ggplot to ggplotly doesn't work with customized 'fill' values in R #421
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
Bug confirmed, thanks. |
I have same issue with geom_boxplots when the fill variable has a different number of levels than the x axis variable set.seed(1234)
dat <- data.frame(cond = factor(rep(c("A","B"), each=200)),
cond2 = factor(rep(c("C","D","E","F"), each=100)),
rating = c(rnorm(200),rnorm(200, mean=.8))
)
dat2 <- data.frame(cond = factor(rep(c("A","B"), each=200)),
cond2 = factor(rep(c("C","D"), each=200))
rating = c(rnorm(200),rnorm(200, mean=.8))
)
p1=ggplot(dat, aes(x=cond, y=rating, fill=cond2)) + geom_boxplot()
p2=ggplot(dat2, aes(x=cond, y=rating, fill=cond2)) + geom_boxplot()
ggplotly(p1)
Warning messages:
1: In if (!grepl(pat, x)) return(x) :
the condition has length > 1 and only the first element will be used
2: In if (!grepl(pat, x)) return(x) :
the condition has length > 1 and only the first element will be used
ggplotly(p2) |
the bug looks to be in line 630 of the gg2list function rm_alpha <- function(x) {
if (length(x) == 0)
return(x)
pat <- "^rgba\\("
if (any(!grepl(pat, x))) # <-------
return(x)
sub(",\\s*[0]?[.]?[0-9]+\\)$", ")", sub(pat, "rgb(",
x))
} |
This should be fixed in f1900cc. Let us know if you still have problems. |
much better but there is still a bug. running the code below brings up the correct graph but when toggling off any of the fill factors (eg yr==2006) interactively it causes the last filled (right most) boxplot to increase in width. library(plotly)
data=read.csv("https://raw.githubusercontent.com/yonicd/CIMDO/master/temp/example.csv",header = T,stringsAsFactors = F)
ggplot(data,aes(x=cut0,y=y3,fill=yr))+geom_boxplot()
ggplotly() |
Trying to use plotly and ggplot to make a geom_bar with a custom colored bar.
ggplot produces this (works):
ggplotly(p) produces this message:
Warning message:
In if (!grepl(pat, x)) return(x) :
the condition has length > 1 and only the first element will be used
And this:

The text was updated successfully, but these errors were encountered: