Created
June 14, 2013 04:12
Revisions
-
vincentchu created this gist
Jun 14, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ rcOpts = {'figure.figsize': (6.0,4.0), # play nicely with white background in the Qt and notebook frontend 'figure.facecolor': 'white', 'figure.edgecolor': 'white', # 12pt labels get cutoff on 6x4 logplots, so use 10pt. 'font.size': 10, # 72 dpi matches SVG/qtconsole # this only affects PNG export, as SVG has no dpi setting 'savefig.dpi': 72, # 10pt still needs a little more room on the xlabel: 'figure.subplot.bottom' : .125 } from io import BytesIO import base64 import matplotlib # matplotlib.interactive(True) matplotlib.interactive(False) from matplotlib import pyplot pyplot.rcParams.update(rcOpts) from pylab import * from matplotlib._pylab_helpers import Gcf plot([1,2,3]) fig = Gcf.get_all_fig_managers()[0].canvas.figure fc = fig.get_facecolor() ec = fig.get_edgecolor() bytes_io = BytesIO() fig.canvas.print_figure(bytes_io, format='png', bbox_inches='tight', facecolor=fc, edgecolor=ec) data = bytes_io.getvalue() print("DATA = %s" %(base64.b64encode(data)))