Last active
April 14, 2017 17:20
-
-
Save cpsievert/b873740854cbfcc7a6c7ce891447c3fb to your computer and use it in GitHub Desktop.
Answer to this question -- https://twitter.com/crude2refined/status/852198071727468544
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotly) | |
library(tidyr) | |
library(crosstalk) | |
m <- gather(mtcars, variable, value, -vs) | |
msd <- SharedData$new(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 = TRUE) %>% layout(margin = list(l = 30)), | |
plot_ly(msd, x = ~jitter(vs), y = ~value) %>% add_markers(alpha = 0.3) | |
) |
Sorry, I didn't make this example with the intention of doing (1).
If I did, I would have done, msd <- SharedData$new(m)
and would have added highlight(off = "plotly_deselect")
, which would solve (2) and (3). The default "off event" is a relayout which can be triggered via the home button
I'm aware of (4), and partially why I made the example, plotly/plotly.R#944
Thanks for bringing up (5), I've seen this before too, but I think it's something that needs to be addressed in plotly.js
I just wanted to show the two different ways of acheiving jitter and acheviing this
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some issues I'm seeing (this is with ggplot2 and plotly installed from GitHub master just now, and crosstalk installed from CRAN):