title: python - uploading a plot from memory to s3 using matplotlib and boto
body: <p>This is my working script that generates a plot, saves it locally to disk, uploads to S3 and deletes the file:</p>
  
  <pre><code>plt.figure(figsize=(6,6))
  plt.plot(x, y, 'bo')
  plt.savefig('file_location')
  
  conn = boto.s3.connect_to_region(
      region_name=AWS_REGION,
      aws_access_key_id=AWS_ACCESS_KEY_ID,
      aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
      calling_format=boto.s3.connection.OrdinaryCallingFormat()
      )
  bucket = conn.get_bucket('bucket_name')
  k = Key(bucket)
  k.key = 'file_name'
  k.set_contents_from_filename('file_location')
  
  os.remove(file_location)
  </code></pre>
  
  <p>What I want is to skip the disk writing and upload the plot directly from memory.</p>
  
  <p>Any suggestions how to achieve that?</p>