【问题标题】:Changing Dimensions of downloaded plot of plotly in r shiny在r闪亮中更改下载情节的尺寸
【发布时间】:2021-10-06 04:29:53
【问题描述】:

我有一个代码,它每次都下载以相同尺寸形成的图形的 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)

【问题讨论】:

    标签: r ggplot2 shiny plotly r-plotly


    【解决方案1】:

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

    plot_ly(
      iris, x = ~get(input$choice), y = ~Sepal.Length, type = 'scatter', mode = 'markers'
    ) %>% config(
      toImageButtonOptions = list(format = "png", width = 1500, height = 750)
    )
    

    【讨论】:

      猜你喜欢
      • 2017-08-12
      • 2018-04-03
      • 2014-09-12
      • 2020-04-30
      • 2019-08-15
      • 2017-09-28
      • 2016-03-25
      • 2017-11-03
      • 1970-01-01
      相关资源
      最近更新 更多