Skip to content

Instantly share code, notes, and snippets.

@hafen
hafen / README.md
Created February 5, 2016 00:53
scatter with webgl
figure(webgl = TRUE) %>%
  ly_points(x, y, data = dat)
@hafen
hafen / README.md
Created February 5, 2016 00:54
scatter with hexbin
figure() %>%
  ly_hexbin(x, y, data = dat)
@hafen
hafen / README.md
Created February 5, 2016 00:56
scatter hexbin to points
range_callback <- custom_callback("
  var rdiff = range.get('end') - range.get('start')
  var zoomed_in = hexbin_glyph.get('_zoomed_in')
  if(rdiff < 1.5) {
    hexbin_glyph.get('_zoomed_in', true)
    points_glyph.set('visible', true)
    points_hov_glyph.set('visible', true)
@hafen
hafen / README.md
Created February 5, 2016 00:59
scatter facet 1
grid_plot(lapply(split(dat, dat$f1), function(d) {
  figure(width = 300, height = 350) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 1, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:00
scatter facet 2
grid_plot(lapply(split(dat, dat$f2), function(d) {
  figure(width = 300, height = 350) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 2, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:15
scatter hexbin to points
range_callback <- custom_callback("
  var rdiff = range.get('end') - range.get('start')
  var zoomed_in = hexbin_glyph.get('_zoomed_in')
  if(rdiff < 1.5) {
    hexbin_glyph.get('_zoomed_in', true)
    points_glyph.set('visible', true)
    points_hov_glyph.set('visible', true)
@hafen
hafen / README.md
Created February 5, 2016 01:30
scatter facet 2
grid_plot(lapply(split(dat, dat$f2), function(d) {
  figure(width = 320, height = 350, tools = NULL) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 2, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:31
scatter facet 2
grid_plot(lapply(split(dat, dat$f2), function(d) {
  figure(width = 300, height = 350, tools = NULL) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 2, same_axes = TRUE)
@hafen
hafen / README.md
Created February 5, 2016 01:32
scatter facet 1
grid_plot(lapply(split(dat, dat$f1), function(d) {
  figure(width = 300, height = 350, tools = NULL) %>%
    ly_hexbin(x, y, data = d, xbnds = bounds, ybnds = bounds)
}), nrow = 1, same_axes = TRUE)
@hafen
hafen / README.md
Created March 1, 2016 18:43
select callback
dat <- data.frame(x = runif(500), y = runif(500))

p <- figure(title = "select points to adjust mean line",
  tools = "lasso_select") %>%
  ly_points(x, y, data = dat, lname = "points") %>%
  ly_lines(x = c(0, 1), y = rep(mean(dat$y), 2), line_width = 6,
 color = "orange", alpha = 0.75, lname = "mean")