I would like to re-open a former topic on StackOverflow, concerning a problem I faced today, which I fixed in the same way as described by matheuscburger, by changing the size of the widget.
Are there new options concerning the possibility to change the size of the HTML widget using saveWidget
from the library htmlwidgets
, in export operation from R
?
Below the sample code:
library(ggplot2)
library(ggiraph)
library(patchwork)
library(cowplot)
mtcars <- mtcars
mtcars$tooltip <- rownames(mtcars)
gg1 <- ggplot(mtcars) +
geom_point_interactive(aes(x = drat, y = wt, color = qsec,
tooltip = tooltip, data_id = tooltip ), size = 4)
gg2 <- ggplot(mtcars) +
geom_point_interactive(aes(x = qsec, y = disp, color = mpg,
tooltip = tooltip, data_id = tooltip ), size = 4)
oggetto <- girafe( ggobj = plot_grid(gg1, gg2), width_svg = 8, height_svg = 4)
oggetto
Below the code for exporting:
library(htmlwidgets)
saveWidget(oggetto, file= "Grafico.html", selfcontained = TRUE, libdir = "libs", knitrOptions = list(width = 1200, height = 500))
With knitrOptions = list(width = 1200, height = 500)
uneffective to defining the sizes.