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

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

Made several changes to try and improve the layout of the plot. Also introduced rotating axis labels to avoid labels being drawn on top of each other.

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