

{"id":3442,"date":"2015-05-26T17:04:44","date_gmt":"2015-05-26T22:04:44","guid":{"rendered":"http:\/\/rud.is\/b\/?p=3442"},"modified":"2018-03-07T16:43:48","modified_gmt":"2018-03-07T21:43:48","slug":"a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/","title":{"rendered":"A quick, incomplete comparison of ggplot2 &#038; rbokeh plotting idioms"},"content":{"rendered":"<p>I set aside a small bit of time to give [rbokeh](https:\/\/github.com\/bokeh\/rbokeh) a try and figured I&#8217;d share a small bit of code that shows how to make the &#8220;same&#8221; chart in both ggplot2 and rbokeh. <\/p>\n<p>#### What is Bokeh\/rbokeh?<\/p>\n<p>rbokeh is an [htmlwidget](http:\/\/htmlwidgets.org) wrapper for the [Bokeh](http:\/\/bokeh.pydata.org\/en\/latest\/) visualization library that has become quite popular in Python circles. Bokeh makes creating interactive charts pretty simple and rbokeh lets you do it all with R syntax.<\/p>\n<p>#### Comparing ggplot &#038; rbokeh<\/p>\n<p>This is not a comprehensive introduction into rbokeh. You can get that [here (officially)](http:\/\/hafen.github.io\/rbokeh\/). I merely wanted to show how a ggplot idiom would map to an rbokeh one for those that may be looking to try out the rbokeh library and are familiar with ggplot. They share a very common &#8220;grammar of graphics&#8221; base where you have a plot structure and add layers and aesthetics. They each do this a tad bit differently, though, as you&#8217;ll see.<\/p>\n<p>First, let&#8217;s plot a line graph with some markers in ggplot. The data I&#8217;m using is a small time series that we&#8217;ll use to plot a cumulative sum of via a line graph. It&#8217;s small enough to fit inline:<\/p>\n<pre lang=\"rsplus\">library(ggplot2)\r\nlibrary(rbokeh)\r\nlibrary(htmlwidgets)\r\n\r\nstructure(list(wk = structure(c(16069, 16237, 16244, 16251, 16279,\r\n16286, 16300, 16307, 16314, 16321, 16328, 16335, 16342, 16349,\r\n16356, 16363, 16377, 16384, 16391, 16398, 16412, 16419, 16426,\r\n16440, 16447, 16454, 16468, 16475, 16496, 16503, 16510, 16517,\r\n16524, 16538, 16552, 16559, 16566, 16573), class = \"Date\"), n = c(1L,\r\n1L, 1L, 1L, 3L, 1L, 3L, 2L, 4L, 2L, 3L, 2L, 5L, 5L, 1L, 1L, 3L,\r\n3L, 3L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 7L, 1L, 2L, 6L, 7L, 1L, 1L,\r\n1L, 2L, 2L, 7L, 1L)), .Names = c(\"wk\", \"n\"), class = c(\"tbl_df\",\r\n\"tbl\", \"data.frame\"), row.names = c(NA, -38L)) -> by_week\r\n\r\nevents <- data.frame(when=as.Date(c(\"2014-10-09\", \"2015-03-20\", \"2015-05-15\")),\r\n                     what=c(\"Thing1\", \"Thing2\", \"Thing2\"))<\/pre>\n<p>The ggplot version is pretty straightforward:<\/p>\n<pre lang=\"rsplus\">gg <- ggplot()\r\ngg <- gg + geom_vline(data=events,\r\n                      aes(xintercept=as.numeric(when), color=what),\r\n                      linetype=\"dashed\", alpha=1\/2)\r\ngg <- gg + geom_text(data=events,\r\n                     aes(x=when, y=1, label=what, color=what),\r\n                     hjust=1.1, size=3)\r\ngg <- gg + geom_line(data=by_week, aes(x=wk, y=cumsum(n)))\r\ngg <- gg + scale_x_date(expand=c(0, 0))\r\ngg <- gg + scale_y_continuous(limits=c(0, 100))\r\ngg <- gg + labs(x=NULL, y=\"Cumulative Stuff\")\r\ngg <- gg + theme_bw()\r\ngg <- gg + theme(panel.grid=element_blank())\r\ngg <- gg + theme(panel.border=element_blank())\r\ngg <- gg + theme(legend.position=\"none\")\r\ngg<\/pre>\n<p>We:<\/p>\n<p>- setup a base ggplot object<br \/>\n- add a layer of marker lines (which are the 3 `events` dates)<br \/>\n- add a layer of text for the marker lines<br \/>\n- add a layer of the actual line - note that we can use `cumsum(n)` vs pre-compute it<br \/>\n- setup scale and other aesthetic properties<\/p>\n<p>That gives us this:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3443\" data-permalink=\"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/gg\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png?fit=600%2C400&amp;ssl=1\" data-orig-size=\"600,400\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"gg\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png?fit=510%2C340&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png?resize=510%2C340&#038;ssl=1\" alt=\"gg\" width=\"510\" height=\"340\" class=\"aligncenter size-full wp-image-3443\" \/><\/a><\/p>\n<p>Here's a similar structure in rbokeh:<\/p>\n<pre lang=\"rsplus\">figure(width=550, height=375,\r\n       logo=\"grey\", outline_line_alpha=0) %>%\r\n  ly_abline(v=events$when, color=c(\"red\", \"blue\", \"blue\"), type=2, alpha=1\/4) %>%\r\n  ly_text(x=events$when, y=5, color=c(\"red\", \"blue\", \"blue\"),\r\n          text=events$what, align=\"right\", font_size=\"7pt\") %>%\r\n  ly_lines(x=wk, y=cumsum(n), data=by_week) %>%\r\n  y_range(c(0, 100)) %>%\r\n  x_axis(grid=FALSE, label=NULL,\r\n         major_label_text_font_size=\"8pt\",\r\n         axis_line_alpha=0) %>%\r\n  y_axis(grid=FALSE,\r\n         label=\"Cumulative Stuff\",\r\n         minor_tick_line_alpha=0,\r\n         axis_label_text_font_size=\"10pt\",\r\n         axis_line_alpha=0) -> rb\r\nrb<\/pre>\n<p>Here, we set the `width` and `height` and configure some of the initial aesthetic options. Note that `outline_line_alpha=0` is the equivalent of `theme(panel.border=element_blank())`.<\/p>\n<p>The markers and text do not work exactly as one might expect since there's no way to specify a `data` parameter, so we have to set the colors manually. Also, since the target is a browser, points are specified in the same way you would with CSS. However, it's a pretty easy translation from `geom_[hv]line` to `ly_abline` and `geom_text` to `ly_text`.<\/p>\n<p>The `ly_lines` works pretty much like `geom_line`.<\/p>\n<p>Notice that both ggplot and rbokeh can grok dates for plotting (though we do not need the `as.numeric` hack for rbokeh).<\/p>\n<p>rbokeh will auto-compute bounds like ggplot would but I wanted the scale to go from 0 to 100 in each plot. You can think of `y_range` as `ylim` in ggplot.<\/p>\n<p>To configure the axes, you work directly with `x_axis` and `y_axis` parameters vs `theme` elements in ggplot. To turn off only lines, I set the alpha to 0 in each and did the same with the y axis minor tick marks. <\/p>\n<p>Here's the rbokeh result:<\/p>\n<p><center><iframe loading=\"lazy\" style=\"max-width=100%\" src=\"\/b\/iframes\/rbokeh\/rbokeh001.html\" sandbox=\"allow-same-origin allow-scripts\" width=\"100%\" height=\"400\" scrolling=\"no\" seamless=\"seamless\" frameBorder=\"0\"><\/iframe><\/center><\/p>\n<p>NOTE: you can save out the widget with:<\/p>\n<pre lang=\"rsplus\">saveWidget(rb, file=\"rbokeh001.html\")<\/pre>\n<p>and I like to use the following `iframe` settings to include the widgets:<\/p>\n<pre lang=\"html\"><iframe loading=\"lazy\" style=\"max-width=100%\" \r\n        src=\"rbokeh001.html\" \r\n        sandbox=\"allow-same-origin allow-scripts\" \r\n        width=\"100%\" \r\n        height=\"400\" \r\n        scrolling=\"no\" \r\n        seamless=\"seamless\" \r\n        frameBorder=\"0\"><\/iframe><\/pre>\n<p>#### Wrapping up<\/p>\n<p>Hopefully this helped a bit with translating some ggplot idioms over to rbokeh and developing a working mental model of rbokeh plots. As I play with it a bit more I'll add some more examples here in the event there are \"tricks\" that need to be exposed. You can find the code [up on github](https:\/\/gist.github.com\/hrbrmstr\/a3a1be8132530b355bf9) and please feel free to drop a note in the comments if there are better ways of doing what I did or if you have other hints for folks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I set aside a small bit of time to give [rbokeh](https:\/\/github.com\/bokeh\/rbokeh) a try and figured I&#8217;d share a small bit of code that shows how to make the &#8220;same&#8221; chart in both ggplot2 and rbokeh. #### What is Bokeh\/rbokeh? rbokeh is an [htmlwidget](http:\/\/htmlwidgets.org) wrapper for the [Bokeh](http:\/\/bokeh.pydata.org\/en\/latest\/) visualization library that has become quite popular in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[24,666,678,673,674,36,15,91],"tags":[810],"class_list":["post-3442","post","type-post","status-publish","format-standard","hentry","category-charts-graphs","category-d3","category-data-visualization","category-datavis-2","category-dataviz","category-html5","category-javascript","category-r","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A quick, incomplete comparison of ggplot2 &amp; rbokeh plotting idioms - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A quick, incomplete comparison of ggplot2 &amp; rbokeh plotting idioms - rud.is\" \/>\n<meta property=\"og:description\" content=\"I set aside a small bit of time to give [rbokeh](https:\/\/github.com\/bokeh\/rbokeh) a try and figured I&#8217;d share a small bit of code that shows how to make the &#8220;same&#8221; chart in both ggplot2 and rbokeh. #### What is Bokeh\/rbokeh? rbokeh is an [htmlwidget](http:\/\/htmlwidgets.org) wrapper for the [Bokeh](http:\/\/bokeh.pydata.org\/en\/latest\/) visualization library that has become quite popular in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-26T22:04:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-07T21:43:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"A quick, incomplete comparison of ggplot2 &#038; rbokeh plotting idioms\",\"datePublished\":\"2015-05-26T22:04:44+00:00\",\"dateModified\":\"2018-03-07T21:43:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/\"},\"wordCount\":622,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/gg.png\",\"keywords\":[\"post\"],\"articleSection\":[\"Charts &amp; Graphs\",\"d3\",\"Data Visualization\",\"DataVis\",\"DataViz\",\"HTML5\",\"Javascript\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/\",\"name\":\"A quick, incomplete comparison of ggplot2 & rbokeh plotting idioms - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/gg.png\",\"datePublished\":\"2015-05-26T22:04:44+00:00\",\"dateModified\":\"2018-03-07T21:43:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/gg.png?fit=600%2C400&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/gg.png?fit=600%2C400&ssl=1\",\"width\":600,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/05\\\/26\\\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A quick, incomplete comparison of ggplot2 &#038; rbokeh plotting idioms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A quick, incomplete comparison of ggplot2 & rbokeh plotting idioms - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/","og_locale":"en_US","og_type":"article","og_title":"A quick, incomplete comparison of ggplot2 & rbokeh plotting idioms - rud.is","og_description":"I set aside a small bit of time to give [rbokeh](https:\/\/github.com\/bokeh\/rbokeh) a try and figured I&#8217;d share a small bit of code that shows how to make the &#8220;same&#8221; chart in both ggplot2 and rbokeh. #### What is Bokeh\/rbokeh? rbokeh is an [htmlwidget](http:\/\/htmlwidgets.org) wrapper for the [Bokeh](http:\/\/bokeh.pydata.org\/en\/latest\/) visualization library that has become quite popular in [&hellip;]","og_url":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/","og_site_name":"rud.is","article_published_time":"2015-05-26T22:04:44+00:00","article_modified_time":"2018-03-07T21:43:48+00:00","og_image":[{"url":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png","type":"","width":"","height":""}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"A quick, incomplete comparison of ggplot2 &#038; rbokeh plotting idioms","datePublished":"2015-05-26T22:04:44+00:00","dateModified":"2018-03-07T21:43:48+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/"},"wordCount":622,"commentCount":5,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png","keywords":["post"],"articleSection":["Charts &amp; Graphs","d3","Data Visualization","DataVis","DataViz","HTML5","Javascript","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/","url":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/","name":"A quick, incomplete comparison of ggplot2 & rbokeh plotting idioms - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png","datePublished":"2015-05-26T22:04:44+00:00","dateModified":"2018-03-07T21:43:48+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png?fit=600%2C400&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/05\/gg.png?fit=600%2C400&ssl=1","width":600,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2015\/05\/26\/a-quick-incomplete-comparison-of-ggplot2-rbokeh-plotting-idioms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"A quick, incomplete comparison of ggplot2 &#038; rbokeh plotting idioms"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p23idr-Tw","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3364,"url":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/","url_meta":{"origin":3442,"position":0},"title":"A look at airline crashes in R with googlesheets, dplyr &#038; ggplot2","author":"hrbrmstr","date":"2015-03-30","format":false,"excerpt":"Over on The DO Loop, @RickWicklin does a nice job [visualizing the causes of airline crashes](http:\/\/blogs.sas.com\/content\/iml\/2015\/03\/30\/visualizing-airline-crashes\/) in SAS using a mosaic plot. More often than not, I find mosaic plots can be a bit difficult to grok, but Rick's use was spot on and I believe it shows the data\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4285,"url":"https:\/\/rud.is\/b\/2016\/04\/12\/beating-lollipops-into-dumbbells\/","url_meta":{"origin":3442,"position":1},"title":"Beating lollipops into dumbbells","author":"hrbrmstr","date":"2016-04-12","format":false,"excerpt":"Shortly after I added lollipop charts to ggalt I had a few requests for a dumbbell geom. It wasn't difficult to do modify the underlying lollipop Geoms to make a geom_dumbbell(). Here it is in action: library(ggplot2) library(ggalt) # devtools::install_github(\"hrbrmstr\/ggalt\") library(dplyr) # from: https:\/\/plot.ly\/r\/dumbbell-plots\/ URL","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4345,"url":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","url_meta":{"origin":3442,"position":2},"title":"(ggplot2) Exercising with (ggalt) dumbbells","author":"hrbrmstr","date":"2016-04-17","format":false,"excerpt":"I follow the most excellent Pew Research folks on Twitter to stay in tune with what's happening (statistically speaking) with the world. Today, they tweeted this excerpt from their 2015 Global Attitudes survey: The age gap in social media use around the world https:\/\/t.co\/0Dq1PcbExG pic.twitter.com\/9HBM7gLxwR\u2014 PewResearch Internet (@pewinternet) April 17,\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3693,"url":"https:\/\/rud.is\/b\/2015\/09\/30\/for-some-definition-of-directly-andor-contort\/","url_meta":{"origin":3442,"position":3},"title":"For Some Definition of &#8220;Directly&#8221; and\/or &#8220;Contort&#8221;","author":"hrbrmstr","date":"2015-09-30","format":false,"excerpt":"Junk Charts did a post on [Don't pick your tool before having your design](http:\/\/junkcharts.typepad.com\/junk_charts\/2015\/09\/dont-pick-your-tool-before-having-your-design.html) and made a claim that this: _\"cannot be produced directly from a tool (without contorting your body in various painful locations)\"_. I beg to differ. With R & ggplot2, I get to both pick my tool\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"https:\/\/rud.is\/b\/category\/data-visualization\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3665,"url":"https:\/\/rud.is\/b\/2015\/09\/08\/roll-your-own-stats-and-geoms-in-ggplot2-part-1-splines\/","url_meta":{"origin":3442,"position":4},"title":"Roll Your Own Stats and Geoms in ggplot2 (Part 1: Splines!)","author":"hrbrmstr","date":"2015-09-08","format":false,"excerpt":"A huge change is coming to ggplot2 and you can get a preview of it over at Hadley's github repo. I've been keenly interested in this as I will be fixing, finishing & porting coord_proj to it once it's done. Hadley & Winston have re-built ggplot2 with an entirely new\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"https:\/\/rud.is\/b\/category\/data-visualization\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3649,"url":"https:\/\/rud.is\/b\/2015\/08\/27\/coloring-and-drawing-outside-the-lines-in-ggplot\/","url_meta":{"origin":3442,"position":5},"title":"Coloring (and Drawing) Outside the Lines in ggplot","author":"hrbrmstr","date":"2015-08-27","format":false,"excerpt":"Time for another Twitter-inspired blog post this week, this time from a tweet by @JonKalodimos: Is there a way to do this in #rstats #ggplot2 https:\/\/t.co\/kxWQFlYpbB\u2014 Jonathan Kalodimos (@JonKalodimos) August 27, 2015 I had seen and appreciated Ann's post on her makeover of the main graphic in [NPR's story](http:\/\/www.npr.org\/sections\/money\/2014\/10\/21\/357629765\/when-women-stopped-coding) and\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"https:\/\/rud.is\/b\/category\/data-visualization\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=3442"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3442\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=3442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=3442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=3442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}