Skip to content

plotly not showing legend when using ggplot2::geom_line() #476

@lucacerone

Description

@lucacerone

Plotly (version 2.4.4) does not convert correctly legends in plots that have only lines,
for example:

library(ggplot2)
library(plotly)
p <- ggplot(iris, aes(x=Sepal.Width, y = Sepal.Length, color=Species)) + geom_line()
p #note: ggplot2 puts a legend here
ggplotly(p) #does not show the legend

whereas works as expected:

library(ggplot2)
library(plotly)
p <- ggplot(iris, aes(x=Sepal.Width, y = Sepal.Length, color=Species)) + geom_point()
p #note: ggplot2 puts a legend here
ggplotly(p) #plotly puts the legend

here is the output of devtools::session_info()

Session info ----------------------------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, linux-gnu           
 ui       RStudio (0.99.486)          
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2016-03-02                  

Packages --------------------------------------------------------------------------------------------------------------------------------------------------------------------
 package     * version     date       source                          
 base64enc     0.1-3       2015-07-28 CRAN (R 3.2.3)                  
 colorspace    1.2-6       2015-03-11 CRAN (R 3.2.3)                  
 devtools      1.10.0.9000 2016-01-29 Github (hadley/devtools@2c08890)
 digest        0.6.9       2016-01-08 CRAN (R 3.2.3)                  
 ggplot2     * 2.0.0       2015-12-18 CRAN (R 3.2.3)                  
 gridExtra     2.2.1       2016-02-29 CRAN (R 3.2.3)                  
 gtable        0.2.0       2016-02-26 CRAN (R 3.2.3)                  
 htmltools     0.3         2015-12-29 CRAN (R 3.2.3)                  
 htmlwidgets   0.6         2016-02-25 CRAN (R 3.2.3)                  
 httr          1.1.0       2016-01-28 CRAN (R 3.2.3)                  
 jsonlite      0.9.19      2015-11-28 CRAN (R 3.2.3)                  
 labeling      0.3         2014-08-23 CRAN (R 3.2.3)                  
 magrittr      1.5         2014-11-22 CRAN (R 3.2.3)                  
 memoise       1.0.0       2016-01-29 CRAN (R 3.2.3)                  
 munsell       0.4.3       2016-02-13 CRAN (R 3.2.3)                  
 plotly      * 2.4.4       2016-02-29 Github (ropensci/plotly@b79e9d2)
 plyr          1.8.3       2015-06-12 CRAN (R 3.2.3)                  
 R6            2.1.2       2016-01-26 CRAN (R 3.2.3)                  
 Rcpp          0.12.3      2016-01-10 CRAN (R 3.2.3)                  
 scales        0.4.0       2016-02-26 CRAN (R 3.2.3)                  
 viridis       0.3.2       2015-12-31 CRAN (R 3.2.3)                  
 yaml          2.1.13      2014-06-12 CRAN (R 3.2.3) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions