早上好,
我正在尝试修复“重新调整尺寸”图后面的输出下载按钮,但到目前为止我还没有得到解决方案。你有什么想法吗?
这是一个示例代码:
ui <- fluidPage(
titlePanel(
sidebarLayout(
sidebarPanel(
wellPanel(h3("Feed the parameters below"))),
mainPanel(
tabsetPanel(
tabPanel(
h4("plot"),
plotOutput(outputId = "plot"),
downloadButton(outputId = "download_plot", label = "Download plot")))))))
server <- function(input, output){
plot_input <- reactive({
p <- ggplot(data=ChickWeight, aes(x=Time, y=weight, color=Diet, group=Chick)) + geom_line()
})
output$plot <- renderPlot({
print(plot_input())}, width = 1200, height = 800)}
output$download_plot <- downloadHandler(
filename = function() { paste0("plot_", Sys.Date(), ".png") },
content = function(file) {
device <- function(..., width, height) {
grDevices::png(..., height = 20, res = 300, units = "cm")}
ggsave(file, plot = plot_input(), device = device)
})
shinyApp(ui = ui, server = server)
