在 r 闪亮中更改 plotly 下载图的尺寸

我有一个代码,它每次都下载以相同尺寸绘制的图形的 png 图像。我想生成一个质量更高的图像。就像我点击图表右上角提供的按钮一样,它应该以不同的尺寸下载

参考代码如下

library(shiny)
library(plotly)

ui <- fluidPage(
  selectInput("choice","Choose",choices = names(iris),selected = NULL),plotlyOutput("graph")
  )

server <- function(input,output,session){

  output$graph <- renderPlotly({
    plot_ly(iris,x = ~get(input$choice),y = ~Sepal.Length,type = 'scatter',mode = 'markers')
  })
}

shinyApp(ui,server)
lyyliu 回答:在 r 闪亮中更改 plotly 下载图的尺寸

您可以在 toImageButtonOptions 函数中使用 config 来设置尺寸:

plot_ly(
  iris,x = ~get(input$choice),y = ~Sepal.Length,type = 'scatter',mode = 'markers'
) %>% config(
  toImageButtonOptions = list(format = "png",width = 1500,height = 750)
)
本文链接:https://www.f2er.com/8648.html

大家都在问