@@ -31,18 +31,34 @@ subplot(p, scatterplot, shareY = TRUE) %>%
31
31
)
32
32
33
33
34
- library(plotly )
35
- library(crosstalk )
36
34
37
35
tx <- SharedData $ new(txhousing , ~ city )
38
- p1 <- ggplot(tx , aes(date , median , group = city )) + geom_line()
36
+ p1 <- ggplot(tx , aes(date , median , group = city )) + geom_line() + xlab( NULL )
39
37
p2 <- plot_ly(tx , x = ~ median , color = I(" black" )) %> %
40
38
add_histogram(histnorm = " probability density" )
41
39
42
- subplot(p1 , p2 ) %> %
40
+ subplot(p1 , p2 , titleX = TRUE , titleY = TRUE ) %> %
43
41
layout(barmode = " overlay" ) %> %
44
42
highlight(
45
43
dynamic = TRUE , persistent = TRUE ,
46
44
selected = attrs_selected(opacity = 0.3 )
47
45
)
48
46
47
+
48
+
49
+
50
+ d <- SharedData $ new(mpg )
51
+ dots <- plot_ly(d , color = ~ class , x = ~ displ , y = ~ cyl )
52
+ boxs <- plot_ly(d , color = ~ class , x = ~ class , y = ~ cty ) %> % add_boxplot()
53
+ bars <- plot_ly(d , x = ~ class , color = ~ class )
54
+
55
+ subplot(dots , boxs ) %> %
56
+ subplot(bars , nrows = 2 ) %> %
57
+ layout(
58
+ dragmode = " select" ,
59
+ barmode = " overlay" ,
60
+ showlegend = FALSE
61
+ ) %> %
62
+ highlight(" plotly_selected" )
63
+
64
+
0 commit comments