【问题标题】:Plotly - change file title of the downloaded graphicPlotly - 更改下载图形的文件标题
【发布时间】:2017-11-23 09:27:04
【问题描述】:

我正在我闪亮的应用程序中使用 R 包。 这是一个小例子:

library(shiny)
library(plotly)

ui <- fluidPage(
  plotlyOutput("plot"),
  verbatimTextOutput("event")
)

server <- function(input, output) {

  # renderPlotly() also understands ggplot2 objects!
  output$plot <- renderPlotly({
    plot_ly(mtcars, x = ~mpg, y = ~wt)
  })

  output$event <- renderPrint({
    d <- event_data("plotly_hover")
    if (is.null(d)) "Hover on a point!" else d
  })
}

shinyApp(ui, server)

当我点击图标下载图形时,图形名称为“newplot”:

如何通过例如“ResultDNA(27)”更改名称“newplot(27)”

谢谢。

【问题讨论】:

    标签: shiny plotly


    【解决方案1】:

    目前有两种解决方案:

    1. 在plotly中使用导出功能

      App1

      export(App1 , file = "ResultDNA(27).png")

    2. 您可以首先将图像保存为 HTML,然后使用 htmlwidgets 以所需的格式保存

      App2

      htmlwidgets::saveWidget(App2, file = "ResultDNA(27).html")

    【讨论】:

    • 感谢拉胡尔·阿加瓦尔。很有帮助!
    • 我已经尝试过您的解决方案,但它不起作用。我必须安装 pandoc,之后出现以下错误:此文档格式需要非空 元素。请在元数据中指定“标题”或“页面标题”。回退到 UseMethod 中的 'ResultDNA' 错误:pas de méthode pour 'ggplotly' applicable pour un objet de classe "NULL"。
    • 请检查这些链接可能对您有帮助:plot.ly/r/static-image-exportgithub.com/wch/webshot
    猜你喜欢
    • 1970-01-01
    • 2021-08-30
    • 1970-01-01
    • 1970-01-01
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多