plotly / plotly.R

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

geom_errorbar - error bars displaying incorrectly (horizontal) #710

Open tamilyn opened 8 years ago

tamilyn commented 8 years ago

geom_errorbar - error bars are displayed incorrectly (wrong size) on the horizontal display (does not happen for the vertical (non coord_flip() version)

Sample to reproduce:

dd2 <- data.frame( auc=c(0.268707482993197,0.571428571428571), 
                   high=c(0.407680628614317,0.648343533190079), 
                   low=c(0.129734337372078,0.494513609667063), 
                   Names = c("Firmicutes","Spirochaetes"))

library(ggplot2)
library(plotly)

gx <- ggplot(data=dd2, aes(y=auc, x=Names))  + 
  geom_bar(stat="identity") +   
  geom_errorbar(aes(ymax = high, ymin=low)) +
  coord_flip()
gx

gp <- ggplotly(gx)
gp   # error bars are incorrect size
tamilyn commented 8 years ago

ggplotly does not display the error bars the same as ggplot (which I am assuming is the intention), but a workaround that mostly addresses the issue is to specify some additional parameters for the ggplotly. In this case the following parameters make the error bars look reasonable

geom_errorbar(aes(ymax = high-0.5, ymin=low-0.5,width=0.03,size=.01)