I am trying to create an empty plotly
with a message telling why the plot is empty as a title. I would like to center the message both horizontally and vertically.
I am missing the vertical center :
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")
Just found the option yref = "paper"
, with y = 0.5
for middle position:
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With