Skip to content

Instantly share code, notes, and snippets.

@hafen
hafen / code.R
Created September 30, 2015 21:05
rbokeh themes
p <- figure() %>%
ly_points(Sepal.Length, Sepal.Width, color = Species, data = iris)
# plot with default theme
p
# plot with ggplot2 theme
p %>% set_theme(bk_ggplot_theme)
@hafen
hafen / README.md
Created October 1, 2015 20:10
zillow time panel
 figure(ylab = 'Price / Sq. Metre (AUD)') %>%
  ly_points(time, medListPriceMetre,
    data = x$housing,
    hover = list(time, medListPriceMetre))
@hafen
hafen / README.md
Last active January 30, 2016 17:16
NYC Taxi Manhattan Pickup Region Frequency
figure(ylim = rev(pickft$value), ylab = NULL) %>%
  ly_points(Freq, value, data = pickft,
    hover = pickft)
@hafen
hafen / README.md
Created October 7, 2015 04:43
NYC Taxi Manhattan Pickup/Dropoff Region Frequency
figure() %>%
  ly_bar(value, Freq, color = which, 
    data = both, position = "dodge") %>%
  theme_axis("x", 
    major_label_orientation = 90)
@hafen
hafen / README.md
Created October 7, 2015 05:04
NYC Taxi Manhattan Passenger Number Distribution
figure(ylab = "# passengers") %>% 
 ly_points(fval, q, data = pc_quant)
@hafen
hafen / README.md
Created October 7, 2015 05:11
NYC Taxi Manhattan Ride Time Distribution
figure(ylab = "ride time (minutes)") %>%
 ly_points(fval, q / 60, data = rt_quant)
@hafen
hafen / README.md
Last active October 7, 2015 05:22
NYC Taxi Manhattan Ride Distance Distribution
figure(ylab = "ride distance log10(miles + 1)", height = 450) %>%
ly_points(fval, q, data = rd_quant,
  hover = rd_quant)
@hafen
hafen / README.md
Created October 7, 2015 05:29
NYC Taxi Manhattan Tip Distribution by Payment Type
figure(ylab = "tip amount (USD)", height = 480,
  legend_location = "top_left") %>% 
  ly_points(fval, q, color = paytype, 
    data = subset(tip_quant, q < 100))
@hafen
hafen / README.md
Created October 7, 2015 07:10
NYC Taxi Manhattan Fare vs. Distance by Rate Level
grid_plot(panels, ncol = 4, same_axes = TRUE)
@hafen
hafen / README.md
Created October 7, 2015 07:20
NYC Taxi Manhattan Pickups vs. Time
figure(width = 1200) %>%
  ly_lines(hourly) %>%
  ly_points(hourly, hover = hourly, alpha = 0) %>%
  y_axis(log = 2) %>%
  tool_pan(dimensions = "width") %>%
  tool_wheel_zoom(dimensions = "width")