在 Plotly 中为 newplot.png 指定不同的文件名

dan*_*y74 4 plotly

我在这里找到了 Plotly 配置选项:

https://plot.ly/javascript/configuration-options

https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L22-L86

但是,对于“toImage”按钮(标记为“下载 png 格式的绘图”),我似乎无法配置图像文件的名称。它总是被称为“newplot.png”,但我想给它一个不同的名称。有什么选择吗?

我正在使用 Plotly 的 JavaScript 版本。

小智 6

您可以使用未记录的变量在Plotly配置中进行设置:

  toImageButtonOptions
    // statically override options for toImage modebar button
    // allowed keys are format, filename, width, height, scale
    // see ../components/modebar/buttons.js
Run Code Online (Sandbox Code Playgroud)

例如,您可以输入:

  toImageButtonOptions: {filename:"nameofyourfile"}
Run Code Online (Sandbox Code Playgroud)