-
Notifications
You must be signed in to change notification settings - Fork 631
Closed
Labels
Description
Trying to use plotly and ggplot to make a geom_bar with a custom colored bar.
set.seed(8)
y <- rpois(1000, 2.9)
table(y)
holdThis <- as.data.frame(table(y))
holdThis$cumTotal <- cumsum(holdThis$Freq)
holdThis$percentage <- (as.numeric(holdThis$Freq)/10000) * 100
holdThis$y <- as.numeric(as.character(holdThis$y))
# In practice this will be generated dynamically, but for here I'll just fill them manually.
fillCol <- c('blue', 'blue','blue','blue','blue','blue','red','blue','blue','blue')
p <- ggplot(holdThis, aes(x=y, y=Freq)) + geom_bar(stat='identity', fill= fillCol, color="black", size = .25, alpha = .7) + scale_x_discrete(breaks = y)
ggplotly(p)
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