在colaboratory上使用plt.savefig保存数据 [英] saving figures using plt.savefig on colaboratory

查看:171
本文介绍了在colaboratory上使用plt.savefig保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用协作工具(在线Jupyter笔记本)我有以下代码,我正在使用此功能绘制一些图形,并希望将图形保存在本地我该怎么办?

I am using collaboratory(online jupyter notebook) I have the following code i am plotting some graphs using this functions and want to save plots locally how can I do this ?

def make_plot_comparison(Xlabel,Ylabel,l1,l2,l1_title,l2_title,name): 
    plt.xlabel(Xlabel)
    plt.ylabel(Ylabel)
    plt.plot(l1,label=l1_title)
    plt.plot(l2,label=l2_title)
    plt.legend(loc='center right')
    plt.title(name)
    #plt.xlim(-5, 25)
    plt.savefig("abc.png")
    plt.show()

推荐答案

也许可以独立保存图片

from google.colab import files
plt.savefig("abc.png")
files.download("abc.png") 

https://colab.research.google.com/notebook#fileId =/v2/external/notebooks/io.ipynb& scrollTo = p2E4EKhCWEC5

这篇关于在colaboratory上使用plt.savefig保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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