Skip to content

Commit 18ccf76

Browse files
committed
another binned target example
1 parent ada5660 commit 18ccf76

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

demo/highlight-binned-target.R

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,34 @@ subplot(p, scatterplot, shareY = TRUE) %>%
3131
)
3232

3333

34-
library(plotly)
35-
library(crosstalk)
3634

3735
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)
3937
p2 <- plot_ly(tx, x = ~median, color = I("black")) %>%
4038
add_histogram(histnorm = "probability density")
4139

42-
subplot(p1, p2) %>%
40+
subplot(p1, p2, titleX = TRUE, titleY = TRUE) %>%
4341
layout(barmode = "overlay") %>%
4442
highlight(
4543
dynamic = TRUE, persistent = TRUE,
4644
selected = attrs_selected(opacity = 0.3)
4745
)
4846

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

Comments
 (0)