标题R为中心的空积

时间:2019-06-27 09:38:16

标签: r plotly r-plotly

我正在尝试创建一个空plotly,并显示一条消息,说明为什么该图作为标题为空。我想将消息水平和垂直居中。

我缺少垂直中心:

empty_plot <- function(title = NULL){
  p <- plotly_empty(type = "scatter", mode = "markers") %>%
    config(
      displayModeBar = FALSE
    ) %>%
    layout(
      title = title
    )
  return(p)
}

empty_plot("Why it is empty")

1 个答案:

答案 0 :(得分:0)

仅找到选项yref = "paper",中间位置为y = 0.5

empty_plot <- function(title = NULL){
  p <- plotly_empty(type = "scatter", mode = "markers") %>%
    config(
      displayModeBar = FALSE
    ) %>%
    layout(
      title = list(
        text = title,
        yref = "paper",
        y = 0.5
      )
    )
  return(p)
} 
empty_plot("Why it is empty")