plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.53k stars 623 forks source link

ggplot to ggplotly does not accept variable alpha #1469

Open aljrico opened 5 years ago

aljrico commented 5 years ago

I'm trying to convert a ggplot that has alpha in its aesthetics (it needs to be variable), which works perfectly in ggplot, but ggplotly() outputs an error.

set.seed(666) 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))

p <- ggplot(holdThis, aes(x=y, y=Freq, alpha = Freq)) + geom_bar(stat='identity', fill= 'blue', color="black", size = .25) + scale_x_discrete(breaks = y)

image

ggplotly(p) image

oganm commented 5 years ago

same is true for geom_segment

aaumaitre commented 5 years ago

Any chance you found a solution for this? I have been googling for a few days now with no apparent solution to the problem: It won't translete no matter what I do.

chaoran-chen commented 3 years ago

I also encountered this problem. My current work-around is setting the alpha value through the fill attribute but this does not always work well, so it would be so great if this issue could be fixed!

In the meantime, I believe that it would be really nice if the error message could be modified and point to this issue (to avoid people spending hours on it like myself).