[英]Changing Dimensions of downloaded plot of plotly in r shiny
我有一个代码,它每次都下载以相同尺寸绘制的图形的 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)
您可以在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)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.