I include two ggplotly() graphics in a html file, eg.
library(ggplot2)
library(plotly)
library(htmltools)
g1 <- ggplot(data=data.frame(x=1:10, y=1:10)) +
geom_point(aes(x=x, y=y))
g2 <- ggplot(data=data.frame(x=11:20, y=1:10)) +
geom_point(aes(x=x, y=y))
l1 <- ggplotly(g1)
l2 <- ggplotly(g2)
htmltools::save_html(htmltools::tagList(l1,l2), file ="index.html")
And now want to include an image in the same html file,eg a ggplot2 object:
foto <- imresize(load.image(system.file("ex/logo.tif", package="terra")),0.25)
fotodf <- as.data.frame(foto,wide="c") %>% mutate(rgb.val=rgb(c.1,c.2,c.3))
p <- ggplot(fotodf,aes(x,y))+geom_raster(aes(fill=rgb.val)) + scale_fill_identity() +
scale_y_reverse() + coord_fixed() + theme_void()
or insert the image file into the html file directly. The problem is that I do not find how to insert either the p ggplot object or the logo.tif file into index.html
We could do something like this: