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

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

Added the X axis index labels that allow string labels to be plotted against data.

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
16import numpy
17
18log = logging.getLogger(__name__)
19
20def figureToImage(fig):
21       
22    canvas = FigureCanvas(fig)
23   
24    buffer = StringIO.StringIO()
25    canvas.print_figure(buffer, dpi=fig.get_dpi(), facecolor=fig.get_facecolor(), edgecolor=fig.get_edgecolor())
26    buffer.seek(0)   
27    im = Image.open(buffer)
28   
29    #log.debug("converted figure to image in %s" % (time.time() - st,))
30   
31    return im
32
33def isString(x):
34   
35    if type(x) in [str, numpy.string_]:
36        return True
37    return False
Note: See TracBrowser for help on using the repository browser.