Add a plot title to ggvis

前端 未结 3 1809
鱼传尺愫
鱼传尺愫 2020-12-24 07:23

I want to add a title to a ggvis plot. I can\'t find an example anywhere. It\'s simple to do with other R plots, e.g.

library(ggplot2)
library(ggvis)
x <-         


        
3条回答
  •  猫巷女王i
    2020-12-24 08:04

    Also, to change the font size of the title use this code (adapted from @tonytonov's answer):

    add_title <- function(vis, ..., x_lab = "X units", title = "Plot Title") 
    {
      add_axis(vis, "x", title = x_lab) %>% 
        add_axis("x", orient = "top", ticks = 0, title = title,
                 properties = axis_props(
                   axis = list(stroke = "white"),
                   title = list(fontSize = 32),
                   labels = list(fontSize = 0)
                 ), ...)
    }
    

提交回复
热议问题