How to do it...

  1. Wrap the add_axis() function with several arguments declared to work as a title function:
> library(ggvis)
> ggvis_title <- function(vis, plot_title, title_size = 18, shift = 0, ...){
add_axis(vis, 'x', ticks = 0, orient = 'top',
properties = axis_props( axis = list(strokeWidth = 0),
labels = list(strokeWidth = 0),
grid = list(strokeWidth = 0),
title = list(fontSize = title_size, dy = -shift, ...)),
title = plot_title)
}
  1. Try it on the previous plot:
> sca3 %>% ggvis_title('simple ggvis scatterplot')

The result looks like the following image:

Figure 2.2 - titled ggvis scatterplot.

Now to the explanations.