从 plotly 保存图像 [英] Saving images from plotly

查看:110
本文介绍了从 plotly 保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以不同格式保存使用 plotly 生成的图像?从生成的 HTML 图形中只能下载为 PNG".我需要与图形进行交互(更改旋转,选择要绘制的数据)并为每个在线修改图保存一个 .eps 图形.非常感谢!

How can I save images generated with plotly in different formats? Only "Download as PNG" is possible from the generated HTML figure. I would need to interact with the figure (change rotation, choose which data to plot) and save an .eps figure for each online modified plot. Thanks a lot!

推荐答案

Plotly 支持导出到 EPS(文档中提到你需要 poppler 库)和 Figure对象有一个 write_image 方法,可以将图形保存到文件中.

Plotly supports exporting to EPS (the docs mention that you need the poppler library) and the Figure object has a write_image method that saves a figure to a file.

您可以通过文件名和分辨率使用 widthheight 关键字参数指定格式,代表逻辑像素.

You can specify the format through the filename and the resolution with the width and height keyword arguments, representing logical pixels.

您可以在 Plotly 此处阅读有关静态图像导出的更多信息.这是一个代码示例:

You can read more on static image exporting in Plotly here. This is a code example:

fig.write_image("name.eps", width=1920, height=1080)

为了选择绘制的内容,您必须设置图形的相机控件.

In order to select what is plotted you will have to set the figure's camera controls.

这篇关于从 plotly 保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆