source: qesdi/linplot/trunk/src/linplot/utils.py @ 6161

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/qesdi/linplot/trunk/src/linplot/utils.py@6161
Revision 6161, 761 bytes checked in by pnorton, 11 years ago (diff)

Added the first version of the linplot code.

Line 
1'''
2Created on 15 Dec 2009
3
4@author: pnorton
5'''
6
7import logging
8import StringIO
9
10# seems to be a problem with the position of the legend text with the Cairo backend
11#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas
12
13from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
14
15from linplot.image_import import Image
16
17log = logging.getLogger(__name__)
18
19def figureToImage(fig):
20       
21    canvas = FigureCanvas(fig)
22   
23    buffer = StringIO.StringIO()
24    canvas.print_figure(buffer, dpi=fig.get_dpi(), facecolor=fig.get_facecolor(), edgecolor=fig.get_edgecolor())
25    buffer.seek(0)   
26    im = Image.open(buffer)
27   
28    #log.debug("converted figure to image in %s" % (time.time() - st,))
29   
30    return im
Note: See TracBrowser for help on using the repository browser.