rbokeh Version 0.5.0 Released

[This article was first published on Ryan Hafen, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The rbokeh package version 0.5.0 was recently released. For those not familiar with rbokeh, it is a plotting library based on BokehJS with the goal of making it easy to flexibly create declarative interactive web-based visualizations in R. To get an overview of what you can do with it, please see here.

At the heart of this update is a significant amount of internal retooling to be compatible with the latest BokehJS library and to be more robust in general. There are many improvements to BokehJS which are inherited by supporting it.

You can install the new update with:

install.packages("rbokeh")

A full list of updates is provided at the end of this post. Many of these are too small to warrant extended coverage, but as a whole comprise a significant update. Here are a few examples showing some of the updated functionality.

Maps with Google API Key

Google has somewhat recently required tools that use Google Maps to have a Google Maps API key. Earlier versions of rbokeh don’t support this as it wasn’t supported in BokehJS until the current version.

You can get your own API key here. Once you have a key, you can either set it as an environment variable, GMAP_API_KEY, set it as an option in your R session with options(GMAP_API_KEY=xxx), or provide it explicitly to gmap().

gmap(width = 700, height = 400,
  zoom = 4, lat = 37.5, lng = -96.4,
  map_style = gmap_style("blue_water")) %>%
  ly_points(long, lat, hover = list(name, pop), data = maps::us.cities)

Since the environment this document is being generated from has a Google Maps API key environment variable, the map plot works.

Note that there is an intermittent issue I’ve noticed recently with embedding Google Maps in iframes in Chrome where the plot may show up gray if it was not in view while the page was loaded. If you can’t see the plot above, try refreshing your page. I’m trying to get to the bottom of this but it shouldn’t generally be an issue because using iframes to embed rbokeh plots into web pages isn’t a common use case that I’m aware of.

Bar charts with hover

ly_bar now has a hover argument that will show the size of the bar on hover. Also, bar charts and boxplots can now be plotted on either axis by simply specifying which axes the variables belong to.

figure() %>%
  ly_bar(variety, yield, color = year,
    data = lattice::barley, hover = TRUE) %>%
  theme_axis("x", major_label_orientation = 90)

Updates like this that concern high-level layer functions are usually quite straightforward so if there are any requests for features to add to existing layer functions or new layer functions are desired, please file an issue or better yet, contribute a fix.

Themes

Several improvements were made to themes. While most of these were minor, one bigger update is the ability to apply a theme across a grid plot (instead of theming each plot independently). For example:

idx <- split(1:150, iris$Species)
figs <- lapply(idx, function(x) {
  figure(width = 230, height = 300) %>%
    ly_points(Sepal.Length, Sepal.Width, data = iris[x, ],
      hover = list(Sepal.Length, Sepal.Width))
})
grid_plot(figs, same_axes = TRUE) %>%
  set_theme(bk_ggplot_theme)

What’s next

There are several things I’d like to do with this package. To give an idea of what will hopefully be coming up next:

  • Investigate integrating rbokeh with crosstalk for cross-widget communication.
  • Take advantage of new features in BokehJS for pure JS-side color mapping and legends instead of the complex way it is currently all handled in R and in the process make color mapping, scales, etc. more robust.
  • Clean up JS callback logic and graduate it from its experimental feature status.

Thanks

Many thanks to all the users for your input, issues, and patience. This is still an early growing project but I’m excited about the direction it is going.

If any users feel like there are issues or requests that are not getting the attention they need, please hop on Github and let me know.

Full list of updates in 0.5.0

  • Add spinner for long-loading figures
  • Set default height/width if one or the other is specified
  • Remove resize tool as default
  • Make theme_ functions propagate across grid plot figures
  • Add theme_title to address issue with title props being moved to new element
  • Remove logo by default in grid plot
  • Fix bug in grid plot height calculation
  • Fix issue with multiple mapped attributes and legend
  • Fix issue with bezier legend
  • Fix bug when using custom axes in grid plots
  • Update to BokehJS 0.12.2
  • Add background fill options to theme_legend
  • Add boxplot test using outlier_glyph = NA and remove superfluous boxplot tests
  • Outlier points in ly_boxplot can be customized
  • Replace do.call’s with explicit function calls in ly_boxplot (thanks Steve Lianoglou)
  • Add code coverage
  • Add many more tests for good coverage
  • Update and add examples to docs
  • Add example for point_types
  • Update ly_boxplot to work correctly with both numeric axes and add stat examples
  • Fix bug in html output dimension specification
  • Use independent data source for CRAN packages example in vignette
  • Fix bug in axis updates with num_minor_ticks
  • Fix background and border fill color/alpha
  • Update widget2png to return any JS error messages as string
  • Update catjitter and add example
  • Update gmap documentation
  • Update themes to work better with BokehJS 0.12
  • Add vignettes
  • Make it easier to specify color palettes
  • Update ly_bar to include group information in hover and make hover FALSE by default
  • Fix bug in grid spacer computation
  • Fix bug in ‘empty’ legend glyph attributes to deal with picky 0.12
  • Fix ly_points so it doesn’t progress colors when grouping by other things
  • Fix rbokeh2html to work with Bokeh 0.12 layouts
  • Fix issue with grouping by color in ly_polygons
  • Remove data from legend glyphs to avoid trouble
  • Fix splitting issue with ly_points and ly_lines
  • Make ly_abline work with vectors
  • Make abline with h= or v= work for mixed axis types (date, cat, etc.)
  • Allow ly_bar to use either axis for bars
  • Fix bug where legend glyphs have incorrect data types
  • Add hover to ly_bar
  • Major lintr overhaul
  • Grid plot working with 0.12
  • Make titles work in new grid plots
  • Add title spec for 0.12
  • Fix default sizing for RStudio
  • Better type checking in ly_image
  • Remove padding logic as it is handled in 0.12 now
  • Fix 0.12 compatibility issues with ly_image
  • Fix tool rendering issues
  • Fix unneeded attributes in CategoricalTicker
  • Fix text layer attributes
  • Add notes about how to scrape glyphs from docs
  • Fix bug in glyphs used for legend entries
  • Add comments about possible new hover parameters
  • Remove logo by default
  • Add with_outliers to ly_boxplot to toggle visibility of points outside the whiskers (thanks Steve Lianoglou)
  • Add api_key to gmap
  • Update BokehJS to 0.12.1 and initial adjustment of R code to adapt

To leave a comment for the author, please follow the link and comment on their blog: Ryan Hafen.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)