File: crosstalk-filter-dynamic-axis.R

package info (click to toggle)
r-cran-plotly 4.9.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 26,616 kB
  • sloc: javascript: 137,775; sh: 20; makefile: 6
file content (15 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
library(plotly)
library(tidyr)
library(crosstalk)

m <- gather(mtcars, variable, value, -vs)
msd <- highlight_key(m, ~variable)
gg <- ggplot(msd, aes(factor(vs), value)) + 
  geom_jitter(alpha = 0.3)

bscols(
  widths = c(11, 6, 6),
  filter_select("id", "Select a variable", msd, ~variable, multiple = FALSE),
  ggplotly(gg, dynamicTicks = "y") %>% layout(margin = list(l = 30)),
  plot_ly(msd, x = ~jitter(vs), y = ~value) %>% add_markers(alpha = 0.3)
)