Notice that both ggplot and rbokeh can grok dates for plotting (though we do not need the as.numeric hack for rbokeh). The ly_lines works pretty much like geom_line. However, it’s a pretty easy translation from geom_line to ly_abline and geom_text to ly_text. Also, since the target is a browser, points are specified in the same way you would with CSS. 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. Note that outline_line_alpha=0 is the equivalent of theme(panel.border=element_blank()). Here, we set the width and height and configure some of the initial aesthetic options. Ly_lines(x=wk, y=cumsum(n), data=by_week) %>% Text=events$what, align="right", font_size="7pt") %>% The data I’m using is a small time series that we’ll use to plot a cumulative sum of via a line graph. They each do this a tad bit differently, though, as you’ll see.įirst, let’s plot a line graph with some markers in ggplot. They share a very common “grammar of graphics” base where you have a plot structure and add layers and aesthetics. 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. This is not a comprehensive introduction into rbokeh. Bokeh makes creating interactive charts pretty simple and rbokeh lets you do it all with R syntax. Rbokeh is an htmlwidget wrapper for the Bokeh visualization library that has become quite popular in Python circles. I set aside a small bit of time to give rbokeh a try and figured I’d share a small bit of code that shows how to make the “same” chart in both ggplot2 and rbokeh.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |