【问题标题】:Empty Plotly with centered title R带有居中标题 R 的空绘图
【发布时间】:2019-11-09 07:21:40
【问题描述】:

我正在尝试创建一个空的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")

【问题讨论】:

    标签: r plotly r-plotly


    【解决方案1】:

    刚刚找到选项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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-02
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 1970-01-01
      • 2010-11-10
      • 1970-01-01
      • 2016-07-20
      相关资源
      最近更新 更多