【问题标题】:Saving plotly plots in one pdf file将绘图保存在一个 pdf 文件中
【发布时间】:2018-11-29 15:13:55
【问题描述】:

我正在尝试将在 for 循环中生成的情节图保存到一个 pdf 文件中,但 here 说我们需要为此付费

此功能有更新吗?我们真的需要付费才能保存为pdf吗?

【问题讨论】:

  • 作为一种变通方法,您可以将所有图表写入.png plotly docs,然后使用this SO answer 读入所有.png 文件并将它们组合成一个@ 987654326@.

标签: pandas plotly


【解决方案1】:

对于 2 年后仍在寻找快速答案的其他人:

可以将静态绘图导出为 pdf。制作一个情节图,比如fig。这有 .write_image 方法可以导出为多种格式。只需这样做:

fig.write_image("your_image.pdf")

注意:您可能需要安装kaleido(使用它来转换为静态图像)。

pip install -U kaleido

然后:

fig.write_image("your_image.pdf", engine="kaleido")

致谢和参考资料:

【讨论】:

    【解决方案2】:

    我相信您确实需要付费才能保存为 pdf:

    py.plotly.image.save_as(fig, filename='file.pdf')
    
    PlotlyRequestError: Hi there! Accounts on the Community Plan can only download PNG and JPEG (raster) images.
    
    To download publication-quality vector images (SVG, PDF, and EPS), please upgrade your account.
    
    UPGRADE HERE: https://plot.ly/products/cloud
    

    您可以将它们保存为 jpeg 或 png:

    py.plotly.image.save_as(fig, filename='file.png')
    

    【讨论】:

      猜你喜欢
      • 2012-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-21
      • 2018-08-20
      相关资源
      最近更新 更多