根据帖子How to display scatter plot with R Packages:svgPanZoom? 我试图在 R Shiny 中复制一个可缩放的图。有人可以帮我写代码吗?为什么我不能重现此代码?
library(shiny)
library(svglite)
library(svgPanZoom)
# Define UI ----
ui <- shinyUI(bootstrapPage(
# App title ----
headerPanel("Cyl vtree"),
# Main panel for displaying outputs ----
svgPanZoom(
svglite:::inlineSVG(
show(p)
),
controlIconsEnabled = T
)
))
# Define server logic to plot ----
server <- function(input, output) {
output$main_plot <- renderSvgPanZoom({
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_point()
svgPanZoom(p, controlIconsEnabled = T)
})
}
shinyApp(ui, server)