Skip to content

Angled Axis Titles cut off ggplotly #512

@bhive01

Description

@bhive01
require(ggplot2)
require(plotly)

randomName <- function(n) {
    random.string <- rep(NA, n)
    randomizeString <- function(x) {
        a <-sample(letters, 1, replace = TRUE)
        return(a)
    }
    return(paste(c(sapply(random.string, randomizeString, simplify = TRUE)), collapse = ""))
}

xvar = replicate(10, randomName(15))

df1 <- data.frame(x = xvar, y = xvar, z = runif(10) )

g = ggplot(df1, aes(x,y,fill=z)) +
        geom_tile() +
        theme(axis.text.x = element_text(angle = 45, vjust = 1,  size = 12, hjust = 1))

ggplotly(g)

Result looks like this:
screen shot 2016-03-15 at 2 36 08 pm

edit: I will add that 90/270 seems to be ok. It's anything that isn't 0/360 or 90/270 that seems to get cut off.

> devtools::session_info()
Session info ---------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.4 (2016-03-10)
 system   x86_64, darwin13.4.0        
 ui       AQUA                        
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2016-03-15                  

Packages -------------------------------------------------------------------------------------------------------------------------------------------------
 package     * version     date       source                               
 assertthat    0.1         2013-12-06 CRAN (R 3.2.0)                       
 base64enc     0.1-3       2015-07-28 CRAN (R 3.2.0)                       
 colorspace    1.2-6       2015-03-11 CRAN (R 3.2.0)                       
 curl          0.9.6       2016-02-17 CRAN (R 3.2.3)                       
 DBI           0.3.1       2014-09-24 CRAN (R 3.2.0)                       
 devtools      1.10.0.9000 2016-02-26 Github (hadley/devtools@b6a23be)     
 digest        0.6.9       2016-01-08 CRAN (R 3.2.3)                       
 dplyr       * 0.4.3       2015-09-01 CRAN (R 3.2.0)                       
 ggplot2     * 2.1.0       2016-03-01 CRAN (R 3.2.4)                       
 git2r         0.13.1      2015-12-10 CRAN (R 3.2.3)                       
 gridExtra     2.2.1       2016-02-29 CRAN (R 3.2.4)                       
 gtable        0.2.0.9000  2016-02-26 Github (hadley/gtable@0ed36a4)       
 htmltools     0.3         2015-12-29 CRAN (R 3.2.3)                       
 htmlwidgets   0.6.1       2016-03-07 Github (ramnathv/htmlwidgets@2e4ad57)
 httr          1.1.0       2016-01-28 CRAN (R 3.2.3)                       
 jsonlite      0.9.19      2015-11-28 CRAN (R 3.2.2)                       
 knitr         1.12.3      2016-01-22 CRAN (R 3.2.3)                       
 labeling      0.3         2014-08-23 CRAN (R 3.2.0)                       
 lazyeval      0.1.10.9000 2016-03-07 Github (hadley/lazyeval@c823611)     
 lubridate   * 1.3.3       2013-12-31 CRAN (R 3.2.0)                       
 magrittr    * 1.5         2014-11-22 CRAN (R 3.2.0)                       
 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      * 3.4.3       2016-03-15 Github (ropensci/plotly@061e43a)     
 plyr        * 1.8.3.9000  2015-10-16 Github (hadley/plyr@9d8294e)         
 R6            2.1.2       2016-01-26 CRAN (R 3.2.3)                       
 Rcpp          0.12.3      2016-01-10 CRAN (R 3.2.3)                       
 readxl      * 0.1.0.9000  2015-11-02 Github (hadley/readxl@7c7f66b)       
 rstudioapi    0.5         2016-01-24 CRAN (R 3.2.3)                       
 scales        0.4.0.9000  2016-02-26 Github (hadley/scales@646b6a4)       
 stringi       1.0-1       2015-10-22 CRAN (R 3.2.0)                       
 stringr       1.0.0       2015-04-30 CRAN (R 3.2.0)                       
 tidyr       * 0.4.1.9000  2016-02-19 Github (hadley/tidyr@323f54e)        
 viridis       0.3.4       2016-03-15 Github (sjmgarnier/viridis@694d4b8)  
 withr         1.0.1       2016-02-04 CRAN (R 3.2.3)                       
 yaml          2.1.13      2014-06-12 CRAN (R 3.2.0)     

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