
Disable the plotly modebar (toolbar) and legend pop-up
Source:R/ro_ply_disable_toolbar.R
ro_ply_disable_toolbar.RdArguments
- fig
A
plotlyobject (fromplotly::plot_ly()orplotly::ggplotly()).
Details
Removes the plotly modebar (toolbar) for a cleaner look and disables the pop-up for the legend, which improves accessibility for keyboard users.
See also
Other ggplotly:
ro_ply_cursor(),
ro_ply_keyboard_nav_barchart(),
ro_ply_keyboard_nav_bargraph(),
ro_ply_keyboard_nav_legend(),
ro_ply_keyboard_nav_linechart(),
ro_ply_keyboard_nav_trendline()
Other plotly:
ro_ply_add_theme(),
ro_ply_cursor(),
ro_ply_dim(),
ro_ply_focus_linechart(),
ro_ply_keyboard_nav_barchart(),
ro_ply_keyboard_nav_bargraph(),
ro_ply_keyboard_nav_legend(),
ro_ply_keyboard_nav_linechart(),
ro_ply_keyboard_nav_trendline(),
ro_ply_legend_theme(),
ro_ply_theme(),
ro_ply_title()
Examples
if (FALSE) { # \dontrun{
data <- tidyr::tibble(
expand.grid(`Age group` = c("A", "B", "C", "D", "E"), `Sex` = c("Man", "Vrouw")),
`Number of Cases` = sample(1:50, 10, TRUE)
)
library(ggplot2)
library(plotly)
p <- ggplot(data, aes(
x = `Number of Cases`,
y = `Age group`,
fill = Sex,
text = paste0(
"Leeftijdsgroep: <b>", `Age group`, "</b><br>",
"Geslacht: <b>", Sex, "</b><br>",
"Aantal cases: <b>", `Number of Cases`, "</b>"
)
)) +
geom_col(position = "dodge") +
labs(
x = "Aantal cases",
y = "Leeftijdsgroep",
fill = "Geslacht"
)
fig <- ggplotly(p, tooltip = "text")
fig <- ro_ply_keyboard_nav_barchart(fig)
fig <- ro_ply_keyboard_nav_legend(fig)
fig <- ro_ply_disable_toolbar(fig)
fig
} # }