i trying 2 3d scatter plots, drawn rgl package, side-by-side in r markdown document. example:
mfrow3d(nr = 1, nc = 2, sharedmouse = true) plot3d(mtcars[, 1:3], type = "s") plot3d(mtcars[, 4:6], type = "s") rglwidget()
this works when run directly in console when knit html document using r markdown, seems if second plot rendered.
i tried adding knit_hooks$set(webgl = hook_webgl)
, setting chunk option webgl = true
, did not either.
any suggestions appreciated.
this output sessioninfo()
:
r version 3.3.1 (2016-06-21) platform: x86_64-w64-mingw32/x64 (64-bit) running under: windows >= 8 x64 (build 9200) locale: [1] lc_collate=english_united states.1252 lc_ctype=english_united states.1252 [3] lc_monetary=english_united states.1252 lc_numeric=c [5] lc_time=english_united states.1252 attached base packages: [1] stats graphics grdevices utils datasets methods base other attached packages: [1] rgl_0.96.0 tidyr_0.6.0 dplyr_0.5.0 smacof_1.8-13 [5] emojifont_0.3.3 gridextra_2.2.1 knitr_1.14 mass_7.3-45 [9] shinydashboard_0.5.1 shiny_0.13.2 rcolorbrewer_1.1-2 ggplot2_2.1.0 loaded via namespace (and not attached): [1] gtools_3.5.0 splines_3.3.1 lattice_0.20-33 colorspace_1.2-6 [5] htmltools_0.3.5 yaml_2.1.13 base64enc_0.1-3 chron_2.3-47 [9] survival_2.39-4 dbi_0.5 foreign_0.8-66 plyr_1.8.4 [13] stringr_1.1.0 munsell_0.4.3 gtable_0.2.0 htmlwidgets_0.7 [17] evaluate_0.9 latticeextra_0.6-28 httpuv_1.3.3 proto_0.3-10 [21] rcpp_0.12.6 acepack_1.3-3.3 xtable_1.8-2 polynom_1.3-8 [25] scales_0.4.0 formatr_1.4 showtext_0.4-4 gdata_2.17.0 [29] jsonlite_1.0 hmisc_3.17-4 sysfonts_0.5 mime_0.5 [33] weights_0.85 digest_0.6.10 stringi_1.1.1 showtextdb_1.0 [37] grid_3.3.1 tools_3.3.1 magrittr_1.5 tibble_1.2 [41] formula_1.2-1 mice_2.25 cluster_2.0.4 matrix_1.2-6 [45] rsconnect_0.4.3 data.table_1.9.6 nnls_1.4 assertthat_0.1 [49] rmarkdown_1.0.9013 r6_2.1.3 rpart_4.1-10 nnet_7.3-12
this bug in conversion of bounding box decoration javascript code. bounds first plot carried on second one. since calculated unrelated quantities, got weird boxes resulting. bug fixed in version 0.96.1516, on r-forge.
by way, current rgl
don't need hook_webgl
or library(rglwidgets)
. use library(rgl)
, call rglwidget()
if want insert plot. (there's way automatically insert plots without rglwidget()
call, don't recommend it.)
so document this:
```{r echo=true} library(rgl) mfrow3d(nr = 1, nc = 2, sharedmouse = true) plot3d(mtcars[, 1:3], type = "s",) plot3d(mtcars[, 4:6], type = "s") rglwidget() ```
this produces picture below in rgl
0.96.1516:
Comments
Post a Comment