davidgohel / ggiraph

make 'ggplot' graphics interactive
https://davidgohel.github.io/ggiraph
793 stars 73 forks source link

Graph position in RStudio Viewer #64

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi, i got some problems while rendering some outputs: charts appear cut in Viewer: schermata da 2017-07-10 16-33-20

i got problems in notebook/markdown too:

schermata da 2017-07-10 16-34-20

Packages: ggplot 2.2.1; ggiraph 0.4.0 R version 3.3.3 (2017-03-06) "Another Canoe"

davidgohel commented 7 years ago

Can you post also your sessionInfo()?

Can you tell me what viewer you are using? Are you using RStudio viewer on Windows for example or did you open the result in a standard browser?

ghost commented 7 years ago

Sure:

R version 3.3.3 (2017-03-06) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 17.04

locale: [1] LC_CTYPE=it_IT.

UTF-8 LC_NUMERIC=C LC_TIME=it_IT.UTF-8 LC_COLLATE=it_IT.UTF-8
[5] LC_MONETARY=it_IT.UTF-8 LC_MESSAGES=it_IT.UTF-8 LC_PAPER=it_IT.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] gdtools_0.1.4 bindrcpp_0.2 ggiraph_0.4.0 ggthemes_3.4.0 knitr_1.16 dygraphs_1.1.1.4 xts_0.10-0
[8] zoo_1.8-0 dplyr_0.7.1 purrr_0.2.2.2 readr_1.1.1 tidyr_0.6.3 tibble_1.3.3 ggplot2_2.2.1
[15] tidyverse_1.1.1 sp_1.2-5

loaded via a namespace (and not attached): [1] Rcpp_0.12.11 lubridate_1.6.0 lattice_0.20-35 assertthat_0.2.0 rprojroot_1.2 digest_0.6.12
[7] psych_1.7.5 R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 backports_1.1.0 evaluate_0.10.1
[13] httr_1.2.1 highr_0.6 rlang_0.1.1 lazyeval_0.2.0 readxl_1.0.0 uuid_0.1-2
[19] R.utils_2.5.0 R.oo_1.21.0 rmarkdown_1.6 labeling_0.3 stringr_1.2.0 foreign_0.8-67
[25] htmlwidgets_0.8 munsell_0.4.3 broom_0.4.2 modelr_0.1.0 base64enc_0.1-3 mnormt_1.5-5
[31] rvg_0.1.4 htmltools_0.3.6 R.methodsS3_1.7.1 grid_3.3.3 nlme_3.1-131 jsonlite_1.5
[37] gtable_0.2.0 magrittr_1.5 scales_0.4.1 zip_1.0.0 stringi_1.1.5 reshape2_1.4.2
[43] xml2_1.1.1 RColorBrewer_1.1-2 tools_3.3.3 forcats_0.2.0 glue_1.1.1 officer_0.1.4
[49] hms_0.3 rsconnect_0.8 parallel_3.3.3 yaml_2.1.14 colorspace_1.3-2 rvest_0.3.2
[55] bindr_0.1 haven_1.1.0

i'm using RStudio Version 1.0.143 viewer on Ubuntu Gnome

Opening tho markdown html output on Firefox there is not cut problem but i get a smaller plot: schermata da 2017-07-10 16-59-06

*The upper i a ggiraph plot the second is the same but simple ggplot.

davidgohel commented 7 years ago

Thanks, I don't think there is an issue with viewing in browser (you may have not set the width_svg and height_svg parameters), could you try something like:

ggiraph(..., width_svg = 7, height_svg = 5)

About the rstudio viewer issue, it seems output is centered on width and height... I don't know exactly what is happening, I can't reproduce on my mac so I will have to find another machine.

ghost commented 7 years ago

Great, i fix the browser view (still got the rstudio browser too)

For error reproduction on the viewer chart: i used this example https://github.com/davidgohel/ggiraph/blob/master/examples/geom_polygon_interactive.R (i think you already recognize it!)

davidgohel commented 7 years ago

thanks for the feedback.

bschneidr commented 7 years ago

I was able to reproduce this issue on my machine as well. Here's a reprex of the issue.

library(ggplot2)
library(ggiraph)

# create data
ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))

values <- data.frame(
  id = ids,
  value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5) )
positions <- data.frame(
  id = rep(ids, each = 4),
  x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
        0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
  y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
        2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2) )

datapoly <- merge(values, positions, by=c("id"))

datapoly$oc = "alert(this.getAttribute(\"data-id\"))"

# create a ggplot -----
gg_poly_1 <- ggplot(datapoly, aes( x = x, y = y ) ) +
  geom_polygon_interactive(aes(fill = value, group = id,
                               tooltip = value, data_id = value, onclick = oc))

# display ------
ggiraph(code = {print(gg_poly_1)})

RStudio Viewer Result

Session info ``` r devtools::session_info() #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.1 (2017-06-30) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> tz America/New_York #> date 2017-08-22 #> Packages ----------------------------------------------------------------- #> package * version date source #> assertthat 0.2.0 2017-04-11 CRAN (R 3.3.3) #> backports 1.1.0 2017-05-22 CRAN (R 3.4.0) #> base * 3.4.1 2017-06-30 local #> base64enc 0.1-3 2015-07-28 CRAN (R 3.3.0) #> bindr 0.1 2016-11-13 CRAN (R 3.3.2) #> bindrcpp 0.2 2017-06-17 CRAN (R 3.4.0) #> bitops 1.0-6 2013-08-17 CRAN (R 3.3.2) #> colorspace 1.3-2 2016-12-14 CRAN (R 3.3.2) #> compiler 3.4.1 2017-06-30 local #> datasets * 3.4.1 2017-06-30 local #> devtools 1.13.3 2017-08-02 CRAN (R 3.4.1) #> digest 0.6.12 2017-01-27 CRAN (R 3.3.2) #> dplyr 0.7.2 2017-07-20 CRAN (R 3.4.1) #> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.0) #> gdtools * 0.1.5 2017-08-08 CRAN (R 3.4.1) #> ggiraph * 0.4.0 2017-06-24 CRAN (R 3.4.0) #> ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.4.0) #> glue 1.1.1 2017-06-21 CRAN (R 3.4.0) #> graphics * 3.4.1 2017-06-30 local #> grDevices * 3.4.1 2017-06-30 local #> grid 3.4.1 2017-06-30 local #> gtable 0.2.0 2016-02-26 CRAN (R 3.3.1) #> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0) #> htmlwidgets 0.9 2017-07-10 CRAN (R 3.4.1) #> jsonlite 1.5 2017-06-01 CRAN (R 3.4.0) #> knitr 1.17 2017-08-10 CRAN (R 3.4.1) #> labeling 0.3 2014-08-23 CRAN (R 3.3.1) #> lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.2) #> magrittr 1.5 2014-11-22 CRAN (R 3.3.1) #> memoise 1.1.0 2017-04-21 CRAN (R 3.3.3) #> methods * 3.4.1 2017-06-30 local #> munsell 0.4.3 2016-02-13 CRAN (R 3.3.1) #> officer 0.1.5 2017-07-27 CRAN (R 3.4.1) #> pkgconfig 2.0.1 2017-03-21 CRAN (R 3.4.0) #> plyr 1.8.4 2016-06-08 CRAN (R 3.3.0) #> purrr 0.2.3 2017-08-02 CRAN (R 3.4.1) #> R.methodsS3 1.7.1 2016-02-16 CRAN (R 3.3.1) #> R.oo 1.21.0 2016-11-01 CRAN (R 3.3.1) #> R.utils 2.5.0 2016-11-07 CRAN (R 3.3.2) #> R6 2.2.2 2017-06-17 CRAN (R 3.4.0) #> Rcpp 0.12.12 2017-07-15 CRAN (R 3.4.1) #> RCurl 1.95-4.8 2016-03-01 CRAN (R 3.3.1) #> rlang 0.1.2 2017-08-09 CRAN (R 3.4.1) #> rmarkdown 1.6 2017-06-15 CRAN (R 3.4.0) #> rprojroot 1.2 2017-01-16 CRAN (R 3.3.2) #> rvg 0.1.4 2017-06-23 CRAN (R 3.4.0) #> scales 0.4.1 2016-11-09 CRAN (R 3.3.2) #> stats * 3.4.1 2017-06-30 local #> stringi 1.1.5 2017-04-07 CRAN (R 3.3.3) #> stringr 1.2.0 2017-02-18 CRAN (R 3.3.2) #> tibble 1.3.4 2017-08-22 CRAN (R 3.4.1) #> tools 3.4.1 2017-06-30 local #> utils * 3.4.1 2017-06-30 local #> uuid 0.1-2 2015-07-28 CRAN (R 3.3.2) #> webshot 0.4.1 2017-05-31 CRAN (R 3.4.0) #> withr 2.0.0 2017-07-28 CRAN (R 3.4.1) #> XML 3.98-1.9 2017-06-19 CRAN (R 3.4.0) #> xml2 1.1.1 2017-01-24 CRAN (R 3.3.2) #> yaml 2.1.14 2016-11-12 CRAN (R 3.3.2) #> zip 1.0.0 2017-04-25 CRAN (R 3.4.0) ```
davidgohel commented 7 years ago

I think it's ok now, can one of you test? I can not test on ubuntu, I only have access to remote machines...

install.packages(c("gdtools", "rvg"), repos = "https://cran.rstudio.com")
devtools::install_github("davidgohel/ggiraph")
bschneidr commented 7 years ago

This works now on my Windows machine (with Session Info included below). Thanks, David! image

Session info ``` r devtools::session_info() #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.1 (2017-06-30) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> tz America/New_York #> date 2017-09-05 #> Packages ----------------------------------------------------------------- #> package * version date source #> assertthat 0.2.0 2017-04-11 CRAN (R 3.3.3) #> backports 1.1.0 2017-05-22 CRAN (R 3.4.0) #> base * 3.4.1 2017-06-30 local #> base64enc 0.1-3 2015-07-28 CRAN (R 3.3.0) #> bindr 0.1 2016-11-13 CRAN (R 3.4.0) #> bindrcpp 0.2 2017-06-17 CRAN (R 3.4.0) #> colorspace 1.3-2 2016-12-14 CRAN (R 3.3.2) #> compiler 3.4.1 2017-06-30 local #> datasets * 3.4.1 2017-06-30 local #> devtools 1.13.3 2017-08-02 CRAN (R 3.4.1) #> digest 0.6.12 2017-01-27 CRAN (R 3.3.2) #> dplyr 0.7.2 2017-07-20 CRAN (R 3.4.1) #> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.0) #> gdtools * 0.1.6 2017-09-01 CRAN (R 3.4.1) #> ggiraph * 0.4.1 2017-09-05 Github (davidgohel/ggiraph@79dd1d2) #> ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.3.2) #> glue 1.1.1 2017-06-21 CRAN (R 3.4.0) #> graphics * 3.4.1 2017-06-30 local #> grDevices * 3.4.1 2017-06-30 local #> grid 3.4.1 2017-06-30 local #> gtable 0.2.0 2016-02-26 CRAN (R 3.3.1) #> htmltools 0.3.6 2017-04-28 CRAN (R 3.3.3) #> htmlwidgets 0.9 2017-07-10 CRAN (R 3.4.1) #> knitr 1.17 2017-08-10 CRAN (R 3.4.1) #> lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.0) #> magrittr 1.5 2014-11-22 CRAN (R 3.3.1) #> memoise 1.1.0 2017-04-21 CRAN (R 3.3.3) #> methods * 3.4.1 2017-06-30 local #> munsell 0.4.3 2016-02-13 CRAN (R 3.3.1) #> officer 0.1.6 2017-08-30 CRAN (R 3.4.1) #> pkgconfig 2.0.1 2017-03-21 CRAN (R 3.4.0) #> plyr 1.8.4 2016-06-08 CRAN (R 3.3.2) #> purrr 0.2.3 2017-08-02 CRAN (R 3.4.1) #> R.methodsS3 1.7.1 2016-02-16 CRAN (R 3.3.1) #> R.oo 1.21.0 2016-11-01 CRAN (R 3.3.1) #> R.utils 2.5.0 2016-11-07 CRAN (R 3.3.2) #> R6 2.2.2 2017-06-17 CRAN (R 3.4.0) #> Rcpp 0.12.12 2017-07-15 CRAN (R 3.4.0) #> rlang 0.1.2 2017-08-09 CRAN (R 3.4.1) #> rmarkdown 1.6 2017-06-15 CRAN (R 3.4.0) #> rprojroot 1.2 2017-01-16 CRAN (R 3.3.2) #> rvg 0.1.4 2017-06-23 CRAN (R 3.4.1) #> scales 0.5.0 2017-08-24 CRAN (R 3.4.1) #> stats * 3.4.1 2017-06-30 local #> stringi 1.1.5 2017-04-07 CRAN (R 3.3.3) #> stringr 1.2.0 2017-02-18 CRAN (R 3.3.2) #> tibble 1.3.4 2017-08-22 CRAN (R 3.4.1) #> tools 3.4.1 2017-06-30 local #> utils * 3.4.1 2017-06-30 local #> uuid 0.1-2 2015-07-28 CRAN (R 3.3.2) #> withr 2.0.0 2017-07-28 CRAN (R 3.4.0) #> xml2 1.1.1 2017-01-24 CRAN (R 3.3.2) #> yaml 2.1.14 2016-11-12 CRAN (R 3.3.2) #> zip 1.0.0 2017-04-25 CRAN (R 3.3.3) ```
davidgohel commented 7 years ago

thanks!