本文介绍了使用绘图离线将图形生成为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ p
$ b

  plotly.offline.plot({ data:data,layout:layout})

效果很好。该图形正确生成并且html文件被保存到我的当前目录。

我想要的是,使用图标离线,是保存图像(.png,.jpg等)文件。我在正确的轨道上吗?我需要从这里做什么?

解决方案

试试这个

  import plotly.offline 
import plotly.graph_objs as go

plotly.offline.plot({data:[go.Scatter(x = [1,2,3,4],y = [4,3,2,1])],
layout:go.Layout(title =hello world)},
image ='jpeg',image_filename ='test')

并在Chrome中打开


I am working with plotly offline and am able to generate an html file using

plotly.offline.plot({"data": data, "layout": layout})

It works great. The graph is generated correctly and the html file gets saved to my current directory.

What I want, though is, using plotly offline, is to have an image (.png, .jpg, etc.) file saved instead. Am I on the right track? What do I need to do from here?

解决方案

Try this

import plotly.offline
import plotly.graph_objs as go

plotly.offline.plot({"data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
                     "layout": go.Layout(title="hello world")},
                     image='jpeg', image_filename='test')

and open it in Chrome

这篇关于使用绘图离线将图形生成为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 21:39