将使用networkx / matplotlib绘制的图像保存到亚马逊s3?

时间:2012-01-06 07:41:52

标签: amazon-s3 matplotlib networkx

我有一个问题:是否可以将使用networkx和matplotlib绘制的图像保存到亚马逊s3中?

以下是一个例子:

import networkx as nx import matplotlib.pyplot as plt

g = nx.DiGraph()
# the graph is being build....

# now i want to draw the graph.
nx.draw_networkx(g)
plt.savefig('retweet.png') # how do i save the image to amazon s3 ?

g = nx.DiGraph() # the graph is being build.... # now i want to draw the graph. nx.draw_networkx(g) plt.savefig('retweet.png') # how do i save the image to amazon s3 ?

那么如何将图像'retweet.png'保存到亚马逊s3?

我不打算启动大型EC2实例并将文件保存在其中。

相反,我打算在PiCloud运行此代码,而不是将文件保存到amazon s3。

我该怎么做?

最诚挚的问候。

1 个答案:

答案 0 :(得分:0)

您可以使用单独的库将图像存储在s3上,“simples3”http://pypi.python.org/pypi/simples3。从网址引用示例:

s = S3Bucket(bucket,access_key=access_key,secret_key=secret_key)    
s.put("retweet.png", "my content")