5 Toolbar
A toolbar is added by default to the graphs at the top right. It contains by default the download button for the PNG version of the graph.
It can contain other elements depending on the options used. If a zoom has been configured, the zoom options will be added to it. If a selection is configured and the graph is in a shiny application, the selection options will be added to it, i.e. selection and anti-selection.
opts_toolbar()
is used to customize the toolbar, it accepts many arguments. The most noteworthy are detailled below.
5.1 Position
Toolbar position can be defined with function opts_toolbar()
and argument position
.
library(tidyverse)
<- rownames_to_column(mtcars, var = "carname")
mtcars_db
<- ggplot(
gg_scatter data = mtcars_db,
mapping = aes(
x = disp, y = qsec, color = wt,
tooltip = carname, data_id = carname
)+
) geom_point_interactive(
size = 3, hover_nearest = TRUE
)
girafe(
ggobj = gg_scatter,
options = list(
opts_toolbar(position = "bottom")
) )
5.3 Labels
It is possible to change the tooltip labels for the buttons of the toolbar by using the argument tooltips
. This can be handy when a language other than English is used.
girafe(
ggobj = gg_scatter,
options = list(
opts_toolbar(
position = "top",
tooltips = list(
zoom_on = "activattion du pan/zoom",
zoom_off = "désactivation du pan/zoom",
zoom_rect = "zoom en rectangle",
zoom_reset = "reset pan/zoom",
saveaspng = "télécharger en png"
)
)
) )