Open
Description
Hey everyone
I've found a problem. Just launch the code and look at the memory. Then delete "%matplotlib inline" and launch again.
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker
%matplotlib inline
import os
import sys
import StringIO
import urllib, base64
from matplotlib import rcParams
rcParams['figure.figsize'] = (24, 6)
rcParams['figure.dpi'] = 150
OUTPUT_FILENAME = "Asd"
def printHTML(html):
with open(OUTPUT_FILENAME, "a") as outputFile: outputFile.write(html if type(html) == str else html.encode('utf8') )
def friendlyPlot():
figure = plt.Figure()
ax = plt.subplot2grid((1,2), (0,0))
ax.plot( range(1000), range(1000) )
#plt.show()
fig = plt.gcf()
imgdata = StringIO.StringIO()
fig.savefig(imgdata, format='png')
imgdata.seek(0) # rewind the data
image = imgdata.buf.encode('base64').replace('\n', '')
printHTML('<img src="data:image/png;base64,{0}" /><br />'.format(image))
plt.close('all')
imgdata.close()
open(OUTPUT_FILENAME, 'w').close()
for i in range(500):
friendlyPlot()