ggplotly and geom_bar when using dates - latest version of plotly (4.7.0)

后端 未结 1 931
不思量自难忘°
不思量自难忘° 2021-02-11 08:24

Say you have the following df:

x <- as.Date(c(\"1963-06-01\", \"1964-06-01\", \"1965-06-01\",\"1966-06-01\"))
y <- c(1162.7, 975.4, 1280.3, 1380.0)
data&l         


        
相关标签:
1条回答
  • 2021-02-11 08:39

    This appears to be a problem in Mac and seems to be related with the way geom_bar handles dates.

    I found that adding as.POSIXct() fixes the issue.

    x <- c("1963-06-01", "1964-06-01", "1965-06-01","1966-06-01")
    y <- c(1162.7, 975.4, 1280.3, 1380.0)
    data<- data.frame(x, y)
    
    ggplotly(ggplot(data=data) + 
      geom_bar(aes(x = as.POSIXct(x), y = y), stat = "identity"))
    
    0 讨论(0)
提交回复
热议问题