问题
I draw a picture using ggplot2 and want to display it in shinyApp with svgPanZoom packages. But the sactters is disappear. Anybody know why? You can run the following code for detail:
library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)
data<-data.frame(x=1:10,y=1:10)
ui <- shinyUI(bootstrapPage(
svgPanZoomOutput(outputId = "main_plot")
))
server = shinyServer(function(input, output) {
output$main_plot <- renderSvgPanZoom({
p <- ggplot(data, aes(x = x, y = y)) + geom_point()
svgPanZoom(p, controlIconsEnabled = T)
})
})
shinyApp(ui,server)
回答1:
I believe you need to add svglite also
library("svglite")
Then replace svgPanZoom call with this
svgPanZoom(
svglite:::inlineSVG(
show(p)
),
controlIconsEnabled = T
)
来源:https://stackoverflow.com/questions/50055111/how-to-display-scatter-plot-with-r-packagessvgpanzoom