栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 面试经验 > 面试问答

如何以png格式保存Plotly Offline图?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何以png格式保存Plotly Offline图?

offline.plot
方法具有
image='png
image_filename='image_file_name'

属性,可将文件另存为
png

offline.plot({'data': [{'y': [4, 2, 3, 4]}],    'layout': {'title': 'Test Plot',    'font': dict(family='Comic Sans MS', size=16)}},  auto_open=True, image = 'png', image_filename='plot_image',  output_type='file', image_width=800, image_height=600,   filename='temp-plot.html', validate=False)

在上

offline.py
或在线查看更多详细信息
plotly

但是,有一点需要注意的是,由于输出图像是与HTML绑定的,因此它将在浏览器中打开,并要求获得保存图像文件的权限。您可以在浏览器设置中将其关闭。

或者,您可能希望使用查看从plotly到matplotlib的转换

plot_mpl

以下示例来自
offline.py

from plotly.offline import init_notebook_mode, plot_mpl    import matplotlib.pyplot as plt    init_notebook_mode()    fig = plt.figure()    x = [10, 15, 20, 25, 30]    y = [100, 250, 200, 150, 300]    plt.plot(x, y, "o")    plot_mpl(fig)    # If you want to to download an image of the figure as well    plot_mpl(fig, image='png')


转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/640275.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号