I am trying to create a scattered matrix matrix with an interactive choice between geometry elements in separate matrix graphs. This works when I deal with geom_points (inside ggpairs ()). When the user selects points on any of the three lower left individual matrix graphs, then they can see the points highlighted on other matrix graphs. The following is a simple example:
library(GGally) library(ggplot2) library(plotly) dat = mtcars[,1:3] p <- ggpairs(dat) ggplotly(p)
However, in my case, I am trying to use geom_hex instead of geom_points. I hope to develop a way in which the user can select the hexagon in a separate matrix and see all the hexagons in other separate matrices that contain at least one of the observations that made up this original hexagon (s).
I believe that this can be more difficult, because hexagons are generalizations that combine several observations. Below is my progress in this direction:
my_fn <- function(data, mapping, ...){ p <- ggplot(data = data, mapping = mapping) + geom_hex(binwidth=3) p } p <- ggpairs(dat, lower = list(continuous = my_fn)) ggplotly(p)
When I hover over individual hexagons, I get interactive information about their number of samples (which I like). However, when I try to select a hexagon in one matrix, I do not see the corresponding hexagons that contain at least one observation of the original hexagon.
I am relatively familiar with Shiny and R. If you know a method that I can use to solve this problem, please share!
================ Session Information ================
R version 3.3.2 (2016-10-31) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X Mavericks 10.9.5 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] data.table_1.10.0 shiny_0.14.2 hexbin_1.27.1 plotly_4.5.6.9000 [5] ggplot2_2.2.0.9000 GGally_1.3.0 loaded via a namespace (and not attached): [1] Rcpp_0.12.8 colourpicker_0.3 RColorBrewer_1.1-2 plyr_1.8.4 [5] prettyunits_1.0.2 base64enc_0.1-3 tools_3.3.2 progress_1.1.2 [9] digest_0.6.10 jsonlite_1.1 tibble_1.2 gtable_0.2.0 [13] viridisLite_0.1.3 lattice_0.20-34 DBI_0.5-1 crosstalk_0.3.1 [17] yaml_2.1.14 stringr_1.1.0 dplyr_0.5.0 httr_1.2.1 [21] htmlwidgets_0.8 grid_3.3.2 reshape_0.8.6 R6_2.2.0 [25] purrr_0.2.2 tidyr_0.6.0 reshape2_1.4.2 magrittr_1.5 [29] scales_0.4.1.9000 htmltools_0.3.5 assertthat_0.1 mime_0.5 [33] xtable_1.8-2 colorspace_1.3-2 httpuv_1.3.3 labeling_0.3 [37] stringi_1.1.2 miniUI_0.1.1 lazyeval_0.2.0 munsell_0.4.3
matrix r ggplot2 plotly scatter-plot
luckButtered
source share