dinosvg
package version r packageVersion('dinosvg')
dinsvg
is a work in progress, but is designed to support structured svg
output from the gsplot package. The package also has a few annotation pieces built in, limited right now to hovertext
.
create a plot with gsplot
library(gsplot) gs <- gsplot() %>% points(y=1:11, x=1:11, col="blue", pch=18, xlab='pizza', ylab='dogs') %>% points(x=4:11, y=11:4, col="red", pch=1) %>% points(3:5,4:6,side=c(1,4), col='green', pch=14, ylab='cats') %>% lines(2:4, c(2,2.6,2.3), col='blue') gs
library(dinosvg) gs <- gsplot() %>% points(y=1:11, x=1:11, col="blue", pch=18, hovertext=paste0('text:',1:11), xlab='pizza', ylab='dogs', id=paste0('point',1:11), 'fill-opacity'='0.3', 'stroke-opacity'=seq(0,1, length.out = 11)) %>% points(x=4:11, y=11:4, col="red", pch=1, hovertext=paste0('text:',11:4)) %>% points(3:5,4:6,side=c(1,4), col='green', hovertext='green', pch=14, ylab='cats') %>% lines(2:4, c(2,2.6,2.3), col='blue') cat('```xml\n',svg(gs, as.string=TRUE),'\n```')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.