<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/rbokeh-version-0-5-0-released/"></div></div><div><a data-url="https://www.r-bloggers.com/rbokeh-version-0-5-0-released/" data-counturl="https://www.r-bloggers.com/rbokeh-version-0-5-0-released/" data-count="horizontal" data-text="rbokeh Version 0.5.0 Released" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://ryanhafen.com/blog/rbokeh-0-5-0"> Ryan Hafen</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The <a target="_blank" rel="nofollow" href="http://hafen.github.io/rbokeh/">rbokeh package</a> 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 <a target="_blank" rel="nofollow" href="http://hafen.github.io/rbokeh/">here</a>.</p>
<p><span></span></p>
<p>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 <a target="_blank" rel="nofollow" href="http://bokeh.pydata.org/en/latest/docs/releases/0.12.2.html">improvements</a> to BokehJS which are inherited by supporting it.</p>
<p>You can install the new update with:</p>
<pre><code>install.packages(&quot;rbokeh&quot;)
</code></pre>
<p>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.</p>
<h2>Maps with Google API Key</h2>
<p>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.</p>
<p>You can get your own API key <a target="_blank" rel="nofollow" href="https://developers.google.com/maps/documentation/javascript/get-api-key">here</a>. Once you have a key, you can either set it as an environment variable, <code>GMAP_API_KEY</code>, set it as an option in your R session with <code>options(GMAP_API_KEY=xxx)</code>, or provide it explicitly to <code>gmap()</code>.</p>
<p></p>
<pre><code>gmap(width = 700, height = 400,
  zoom = 4, lat = 37.5, lng = -96.4,
  map_style = gmap_style(&quot;blue_water&quot;)) %>%
  ly_points(long, lat, hover = list(name, pop), data = maps::us.cities)
</code></pre>
<p><iframe height="420" width="720" allowfullscreen="" src="https://cdn.rawgit.com/hafen/130929f08c6deb1d4586d0ba8b82dc51/raw/6f1b3c2ff79897142d0bb9abb8aea19ac92bdb96/index.html"></iframe></p>
<p>Since the environment this document is being generated from has a Google Maps API key environment variable, the map plot works.</p>
<p>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.</p>
<h2>Bar charts with hover</h2>
<p><code>ly_bar</code> now has a <code>hover</code> 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.</p>
<p></p>
<pre><code>figure() %>%
  ly_bar(variety, yield, color = year,
    data = lattice::barley, hover = TRUE) %>%
  theme_axis(&quot;x&quot;, major_label_orientation = 90)
</code></pre>
<p><iframe height="500" width="520" allowfullscreen="" src="https://cdn.rawgit.com/hafen/3ec99d7e95a2e487d1dd25c0d17b7c82/raw/16aef1edd992ec94c7049e3037aebd96935ac594/index.html"></iframe></p>
<p>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 <a target="_blank" rel="nofollow" href="https://github.com/bokeh/rbokeh/issues">file an issue</a> or better yet, contribute a fix.</p>
<h2>Themes</h2>
<p>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:</p>
<p></p>
<pre><code>idx &lt;- split(1:150, iris$Species)
figs &lt;- 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)
</code></pre>
<p><iframe height="320" width="710" allowfullscreen="" src="https://cdn.rawgit.com/hafen/b7389ee0eb04edec7c4dcc0d5d9262c7/raw/2cd72b8b8025a64fb56cb8f496d03ce93f64003f/index.html"></iframe></p>
<h2>What’s next</h2>
<p>There are several things I’d like to do with this package. To give an idea of what will hopefully be coming up next:</p>
<ul>
<li>Investigate integrating rbokeh with <a target="_blank" rel="nofollow" href="https://github.com/rstudio/crosstalk">crosstalk</a> for cross-widget communication.</li>
<li>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.</li>
<li>Clean up JS callback logic and graduate it from its experimental feature status.</li>
</ul>
<h2>Thanks</h2>
<p>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.</p>
<p>If any users feel like there are issues or requests that are not getting the attention they need, please hop on <a target="_blank" rel="nofollow" href="https://github.com/bokeh/rbokeh/issues">Github</a> and let me know.</p>
<h2>Full list of updates in 0.5.0</h2>
<ul>
<li>Add spinner for long-loading figures</li>
<li>Set default height/width if one or the other is specified</li>
<li>Remove resize tool as default</li>
<li>Make theme_ functions propagate across grid plot figures</li>
<li>Add <code>theme_title</code> to address issue with title props being moved to new element</li>
<li>Remove logo by default in grid plot</li>
<li>Fix bug in grid plot height calculation</li>
<li>Fix issue with multiple mapped attributes and legend</li>
<li>Fix issue with bezier legend</li>
<li>Fix bug when using custom axes in grid plots</li>
<li>Update to BokehJS 0.12.2</li>
<li>Add background fill options to <code>theme_legend</code></li>
<li>Add boxplot test using <code>outlier_glyph = NA</code> and remove superfluous boxplot tests</li>
<li>Outlier points in <code>ly_boxplot</code> can be customized</li>
<li>Replace <code>do.call</code>’s with explicit function calls in <code>ly_boxplot</code> (thanks Steve Lianoglou)</li>
<li>Add code coverage</li>
<li>Add many more tests for good coverage</li>
<li>Update and add examples to docs</li>
<li>Add example for point_types</li>
<li>Update <code>ly_boxplot</code> to work correctly with both numeric axes and add stat examples</li>
<li>Fix bug in html output dimension specification</li>
<li>Use independent data source for CRAN packages example in vignette</li>
<li>Fix bug in axis updates with <code>num_minor_ticks</code></li>
<li>Fix background and border fill color/alpha</li>
<li>Update <code>widget2png</code> to return any JS error messages as string</li>
<li>Update <code>catjitter</code> and add example</li>
<li>Update <code>gmap</code> documentation</li>
<li>Update themes to work better with BokehJS 0.12</li>
<li>Add vignettes</li>
<li>Make it easier to specify color palettes</li>
<li>Update <code>ly_bar</code> to include group information in hover and make hover FALSE by default</li>
<li>Fix bug in grid spacer computation</li>
<li>Fix bug in ‘empty’ legend glyph attributes to deal with picky 0.12</li>
<li>Fix ly_points so it doesn’t progress colors when grouping by other things</li>
<li>Fix <code>rbokeh2html</code> to work with Bokeh 0.12 layouts</li>
<li>Fix issue with grouping by color in ly_polygons</li>
<li>Remove data from legend glyphs to avoid trouble</li>
<li>Fix splitting issue with <code>ly_points</code> and <code>ly_lines</code></li>
<li>Make <code>ly_abline</code> work with vectors</li>
<li>Make <code>abline</code> with h= or v= work for mixed axis types (date, cat, etc.)</li>
<li>Allow <code>ly_bar</code> to use either axis for bars</li>
<li>Fix bug where legend glyphs have incorrect data types</li>
<li>Add hover to <code>ly_bar</code></li>
<li>Major lintr overhaul</li>
<li>Grid plot working with 0.12</li>
<li>Make titles work in new grid plots</li>
<li>Add title spec for 0.12</li>
<li>Fix default sizing for RStudio</li>
<li>Better type checking in <code>ly_image</code></li>
<li>Remove padding logic as it is handled in 0.12 now</li>
<li>Fix 0.12 compatibility issues with <code>ly_image</code></li>
<li>Fix tool rendering issues</li>
<li>Fix unneeded attributes in CategoricalTicker</li>
<li>Fix text layer attributes</li>
<li>Add notes about how to scrape glyphs from docs</li>
<li>Fix bug in glyphs used for legend entries</li>
<li>Add comments about possible new hover parameters</li>
<li>Remove logo by default</li>
<li>Add <code>with_outliers</code> to <code>ly_boxplot</code> to toggle visibility of points outside the whiskers (thanks Steve Lianoglou)</li>
<li>Add api_key to <code>gmap</code></li>
<li>Update BokehJS to 0.12.1 and initial adjustment of R code to adapt</li>
</ul>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/rbokeh-version-0-5-0-released/"></div></div><div><a data-url="https://www.r-bloggers.com/rbokeh-version-0-5-0-released/" data-counturl="https://www.r-bloggers.com/rbokeh-version-0-5-0-released/" data-count="vertical" data-text="rbokeh Version 0.5.0 Released" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://ryanhafen.com/blog/rbokeh-0-5-0"> Ryan Hafen</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/cZACwDAxDd0"></a></div>