##// END OF EJS Templates
En el metodo createPline se descomenta una seccion del codigo para configurar los xticks del grafico
Daniel Valdez -
r371:ab720301e6a9
parent child
Show More
@@ -1,382 +1,382
1 import numpy
1 import numpy
2 import datetime
2 import datetime
3 import sys
3 import sys
4 import matplotlib
4 import matplotlib
5
5
6 if 'linux' in sys.platform:
6 if 'linux' in sys.platform:
7 matplotlib.use("TKAgg")
7 matplotlib.use("TKAgg")
8
8
9 if 'darwin' in sys.platform:
9 if 'darwin' in sys.platform:
10 matplotlib.use("TKAgg")
10 matplotlib.use("TKAgg")
11
11
12 import matplotlib.pyplot
12 import matplotlib.pyplot
13
13
14 from mpl_toolkits.axes_grid1 import make_axes_locatable
14 from mpl_toolkits.axes_grid1 import make_axes_locatable
15 from matplotlib.ticker import *
15 from matplotlib.ticker import *
16
16
17 ###########################################
17 ###########################################
18 #Actualizacion de las funciones del driver
18 #Actualizacion de las funciones del driver
19 ###########################################
19 ###########################################
20
20
21 def createFigure(idfigure, wintitle, width, height, facecolor="w", show=True):
21 def createFigure(idfigure, wintitle, width, height, facecolor="w", show=True):
22
22
23 matplotlib.pyplot.ioff()
23 matplotlib.pyplot.ioff()
24 fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
24 fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
25 fig.canvas.manager.set_window_title(wintitle)
25 fig.canvas.manager.set_window_title(wintitle)
26 fig.canvas.manager.resize(width, height)
26 fig.canvas.manager.resize(width, height)
27 matplotlib.pyplot.ion()
27 matplotlib.pyplot.ion()
28 if show:
28 if show:
29 matplotlib.pyplot.show()
29 matplotlib.pyplot.show()
30
30
31 return fig
31 return fig
32
32
33 def closeFigure(show=True):
33 def closeFigure(show=True):
34
34
35 matplotlib.pyplot.ioff()
35 matplotlib.pyplot.ioff()
36 if show:
36 if show:
37 matplotlib.pyplot.show()
37 matplotlib.pyplot.show()
38
38
39 return
39 return
40
40
41 def saveFigure(fig, filename):
41 def saveFigure(fig, filename):
42
42
43 matplotlib.pyplot.ioff()
43 matplotlib.pyplot.ioff()
44 fig.savefig(filename)
44 fig.savefig(filename)
45 matplotlib.pyplot.ion()
45 matplotlib.pyplot.ion()
46
46
47 def setWinTitle(fig, title):
47 def setWinTitle(fig, title):
48
48
49 fig.canvas.manager.set_window_title(title)
49 fig.canvas.manager.set_window_title(title)
50
50
51 def setTitle(fig, title):
51 def setTitle(fig, title):
52
52
53 fig.suptitle(title)
53 fig.suptitle(title)
54
54
55 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan):
55 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan):
56
56
57 matplotlib.pyplot.ioff()
57 matplotlib.pyplot.ioff()
58 matplotlib.pyplot.figure(fig.number)
58 matplotlib.pyplot.figure(fig.number)
59 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
59 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
60 (xpos, ypos),
60 (xpos, ypos),
61 colspan=colspan,
61 colspan=colspan,
62 rowspan=rowspan)
62 rowspan=rowspan)
63
63
64 matplotlib.pyplot.ion()
64 matplotlib.pyplot.ion()
65 return axes
65 return axes
66
66
67 def setAxesText(ax, text):
67 def setAxesText(ax, text):
68
68
69 ax.annotate(text,
69 ax.annotate(text,
70 xy = (.1, .99),
70 xy = (.1, .99),
71 xycoords = 'figure fraction',
71 xycoords = 'figure fraction',
72 horizontalalignment = 'left',
72 horizontalalignment = 'left',
73 verticalalignment = 'top',
73 verticalalignment = 'top',
74 fontsize = 10)
74 fontsize = 10)
75
75
76 def printLabels(ax, xlabel, ylabel, title):
76 def printLabels(ax, xlabel, ylabel, title):
77
77
78 ax.set_xlabel(xlabel, size=11)
78 ax.set_xlabel(xlabel, size=11)
79 ax.set_ylabel(ylabel, size=11)
79 ax.set_ylabel(ylabel, size=11)
80 ax.set_title(title, size=12)
80 ax.set_title(title, size=12)
81
81
82 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
82 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
83 ticksize=9, xtick_visible=True, ytick_visible=True,
83 ticksize=9, xtick_visible=True, ytick_visible=True,
84 nxticks=4, nyticks=10,
84 nxticks=4, nyticks=10,
85 grid=None):
85 grid=None):
86
86
87 """
87 """
88
88
89 Input:
89 Input:
90 grid : None, 'both', 'x', 'y'
90 grid : None, 'both', 'x', 'y'
91 """
91 """
92
92
93 matplotlib.pyplot.ioff()
93 matplotlib.pyplot.ioff()
94
94
95 ax.set_xlim([xmin,xmax])
95 ax.set_xlim([xmin,xmax])
96 ax.set_ylim([ymin,ymax])
96 ax.set_ylim([ymin,ymax])
97
97
98 printLabels(ax, xlabel, ylabel, title)
98 printLabels(ax, xlabel, ylabel, title)
99
99
100 ######################################################
100 ######################################################
101 # if (xmax-xmin)<=1:
101 if (xmax-xmin)<=1:
102 # xtickspos = numpy.linspace(xmin,xmax,nxticks)
102 xtickspos = numpy.linspace(xmin,xmax,nxticks)
103 # xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
103 xtickspos = numpy.array([float("%.1f"%i) for i in xtickspos])
104 # ax.set_xticks(xtickspos)
104 ax.set_xticks(xtickspos)
105 # else:
105 else:
106 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
106 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
107 # ax.set_xticks(xtickspos)
107 ax.set_xticks(xtickspos)
108 #
108
109 # for tick in ax.get_xticklabels():
109 for tick in ax.get_xticklabels():
110 # tick.set_visible(xtick_visible)
110 tick.set_visible(xtick_visible)
111 #
111
112 # for tick in ax.xaxis.get_major_ticks():
112 for tick in ax.xaxis.get_major_ticks():
113 # tick.label.set_fontsize(ticksize)
113 tick.label.set_fontsize(ticksize)
114
114
115 ######################################################
115 ######################################################
116 for tick in ax.get_yticklabels():
116 for tick in ax.get_yticklabels():
117 tick.set_visible(ytick_visible)
117 tick.set_visible(ytick_visible)
118
118
119 for tick in ax.yaxis.get_major_ticks():
119 for tick in ax.yaxis.get_major_ticks():
120 tick.label.set_fontsize(ticksize)
120 tick.label.set_fontsize(ticksize)
121
121
122 ax.plot(x, y)
122 ax.plot(x, y)
123 iplot = ax.lines[-1]
123 iplot = ax.lines[-1]
124
124
125 ######################################################
125 ######################################################
126 if '0.' in matplotlib.__version__[0:2]:
126 if '0.' in matplotlib.__version__[0:2]:
127 print "The matplotlib version has to be updated to 1.1 or newer"
127 print "The matplotlib version has to be updated to 1.1 or newer"
128 return iplot
128 return iplot
129
129
130 if '1.0.' in matplotlib.__version__[0:4]:
130 if '1.0.' in matplotlib.__version__[0:4]:
131 print "The matplotlib version has to be updated to 1.1 or newer"
131 print "The matplotlib version has to be updated to 1.1 or newer"
132 return iplot
132 return iplot
133
133
134 if grid != None:
134 if grid != None:
135 ax.grid(b=True, which='major', axis=grid)
135 ax.grid(b=True, which='major', axis=grid)
136
136
137 matplotlib.pyplot.tight_layout()
137 matplotlib.pyplot.tight_layout()
138
138
139 matplotlib.pyplot.ion()
139 matplotlib.pyplot.ion()
140
140
141 return iplot
141 return iplot
142
142
143 def set_linedata(ax, x, y, idline):
143 def set_linedata(ax, x, y, idline):
144
144
145 ax.lines[idline].set_data(x,y)
145 ax.lines[idline].set_data(x,y)
146
146
147 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
147 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
148
148
149 ax = iplot.get_axes()
149 ax = iplot.get_axes()
150
150
151 printLabels(ax, xlabel, ylabel, title)
151 printLabels(ax, xlabel, ylabel, title)
152
152
153 set_linedata(ax, x, y, idline=0)
153 set_linedata(ax, x, y, idline=0)
154
154
155 def addpline(ax, x, y, color, linestyle, lw):
155 def addpline(ax, x, y, color, linestyle, lw):
156
156
157 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
157 ax.plot(x,y,color=color,linestyle=linestyle,lw=lw)
158
158
159
159
160 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
160 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
161 xlabel='', ylabel='', title='', ticksize = 9,
161 xlabel='', ylabel='', title='', ticksize = 9,
162 colormap='jet',cblabel='', cbsize="5%",
162 colormap='jet',cblabel='', cbsize="5%",
163 XAxisAsTime=False):
163 XAxisAsTime=False):
164
164
165 matplotlib.pyplot.ioff()
165 matplotlib.pyplot.ioff()
166
166
167 divider = make_axes_locatable(ax)
167 divider = make_axes_locatable(ax)
168 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
168 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
169 fig = ax.get_figure()
169 fig = ax.get_figure()
170 fig.add_axes(ax_cb)
170 fig.add_axes(ax_cb)
171
171
172 ax.set_xlim([xmin,xmax])
172 ax.set_xlim([xmin,xmax])
173 ax.set_ylim([ymin,ymax])
173 ax.set_ylim([ymin,ymax])
174
174
175 printLabels(ax, xlabel, ylabel, title)
175 printLabels(ax, xlabel, ylabel, title)
176
176
177 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
177 imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
178 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
178 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
179 cb.set_label(cblabel)
179 cb.set_label(cblabel)
180
180
181 # for tl in ax_cb.get_yticklabels():
181 # for tl in ax_cb.get_yticklabels():
182 # tl.set_visible(True)
182 # tl.set_visible(True)
183
183
184 for tick in ax.yaxis.get_major_ticks():
184 for tick in ax.yaxis.get_major_ticks():
185 tick.label.set_fontsize(ticksize)
185 tick.label.set_fontsize(ticksize)
186
186
187 for tick in ax.xaxis.get_major_ticks():
187 for tick in ax.xaxis.get_major_ticks():
188 tick.label.set_fontsize(ticksize)
188 tick.label.set_fontsize(ticksize)
189
189
190 for tick in cb.ax.get_yticklabels():
190 for tick in cb.ax.get_yticklabels():
191 tick.set_fontsize(ticksize)
191 tick.set_fontsize(ticksize)
192
192
193 ax_cb.yaxis.tick_right()
193 ax_cb.yaxis.tick_right()
194
194
195 if '0.' in matplotlib.__version__[0:2]:
195 if '0.' in matplotlib.__version__[0:2]:
196 print "The matplotlib version has to be updated to 1.1 or newer"
196 print "The matplotlib version has to be updated to 1.1 or newer"
197 return imesh
197 return imesh
198
198
199 if '1.0.' in matplotlib.__version__[0:4]:
199 if '1.0.' in matplotlib.__version__[0:4]:
200 print "The matplotlib version has to be updated to 1.1 or newer"
200 print "The matplotlib version has to be updated to 1.1 or newer"
201 return imesh
201 return imesh
202
202
203 matplotlib.pyplot.tight_layout()
203 matplotlib.pyplot.tight_layout()
204
204
205 if XAxisAsTime:
205 if XAxisAsTime:
206
206
207 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
207 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
208 ax.xaxis.set_major_formatter(FuncFormatter(func))
208 ax.xaxis.set_major_formatter(FuncFormatter(func))
209 ax.xaxis.set_major_locator(LinearLocator(7))
209 ax.xaxis.set_major_locator(LinearLocator(7))
210
210
211 matplotlib.pyplot.ion()
211 matplotlib.pyplot.ion()
212 return imesh
212 return imesh
213
213
214 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
214 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
215
215
216 z = z.T
216 z = z.T
217
217
218 ax = imesh.get_axes()
218 ax = imesh.get_axes()
219
219
220 printLabels(ax, xlabel, ylabel, title)
220 printLabels(ax, xlabel, ylabel, title)
221
221
222 imesh.set_array(z.ravel())
222 imesh.set_array(z.ravel())
223
223
224 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
224 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
225
225
226 printLabels(ax, xlabel, ylabel, title)
226 printLabels(ax, xlabel, ylabel, title)
227
227
228 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
228 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
229
229
230 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
230 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
231
231
232 printLabels(ax, xlabel, ylabel, title)
232 printLabels(ax, xlabel, ylabel, title)
233
233
234 ax.collections.remove(ax.collections[0])
234 ax.collections.remove(ax.collections[0])
235
235
236 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
236 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
237
237
238 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
238 def createPmultiline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
239 ticksize=9, xtick_visible=True, ytick_visible=True,
239 ticksize=9, xtick_visible=True, ytick_visible=True,
240 nxticks=4, nyticks=10,
240 nxticks=4, nyticks=10,
241 grid=None):
241 grid=None):
242
242
243 """
243 """
244
244
245 Input:
245 Input:
246 grid : None, 'both', 'x', 'y'
246 grid : None, 'both', 'x', 'y'
247 """
247 """
248
248
249 matplotlib.pyplot.ioff()
249 matplotlib.pyplot.ioff()
250
250
251 lines = ax.plot(x.T, y)
251 lines = ax.plot(x.T, y)
252 leg = ax.legend(lines, legendlabels, loc='upper right')
252 leg = ax.legend(lines, legendlabels, loc='upper right')
253 leg.get_frame().set_alpha(0.5)
253 leg.get_frame().set_alpha(0.5)
254 ax.set_xlim([xmin,xmax])
254 ax.set_xlim([xmin,xmax])
255 ax.set_ylim([ymin,ymax])
255 ax.set_ylim([ymin,ymax])
256 printLabels(ax, xlabel, ylabel, title)
256 printLabels(ax, xlabel, ylabel, title)
257
257
258 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
258 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
259 ax.set_xticks(xtickspos)
259 ax.set_xticks(xtickspos)
260
260
261 for tick in ax.get_xticklabels():
261 for tick in ax.get_xticklabels():
262 tick.set_visible(xtick_visible)
262 tick.set_visible(xtick_visible)
263
263
264 for tick in ax.xaxis.get_major_ticks():
264 for tick in ax.xaxis.get_major_ticks():
265 tick.label.set_fontsize(ticksize)
265 tick.label.set_fontsize(ticksize)
266
266
267 for tick in ax.get_yticklabels():
267 for tick in ax.get_yticklabels():
268 tick.set_visible(ytick_visible)
268 tick.set_visible(ytick_visible)
269
269
270 for tick in ax.yaxis.get_major_ticks():
270 for tick in ax.yaxis.get_major_ticks():
271 tick.label.set_fontsize(ticksize)
271 tick.label.set_fontsize(ticksize)
272
272
273 iplot = ax.lines[-1]
273 iplot = ax.lines[-1]
274
274
275 if '0.' in matplotlib.__version__[0:2]:
275 if '0.' in matplotlib.__version__[0:2]:
276 print "The matplotlib version has to be updated to 1.1 or newer"
276 print "The matplotlib version has to be updated to 1.1 or newer"
277 return iplot
277 return iplot
278
278
279 if '1.0.' in matplotlib.__version__[0:4]:
279 if '1.0.' in matplotlib.__version__[0:4]:
280 print "The matplotlib version has to be updated to 1.1 or newer"
280 print "The matplotlib version has to be updated to 1.1 or newer"
281 return iplot
281 return iplot
282
282
283 if grid != None:
283 if grid != None:
284 ax.grid(b=True, which='major', axis=grid)
284 ax.grid(b=True, which='major', axis=grid)
285
285
286 matplotlib.pyplot.tight_layout()
286 matplotlib.pyplot.tight_layout()
287
287
288 matplotlib.pyplot.ion()
288 matplotlib.pyplot.ion()
289
289
290 return iplot
290 return iplot
291
291
292
292
293 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
293 def pmultiline(iplot, x, y, xlabel='', ylabel='', title=''):
294
294
295 ax = iplot.get_axes()
295 ax = iplot.get_axes()
296
296
297 printLabels(ax, xlabel, ylabel, title)
297 printLabels(ax, xlabel, ylabel, title)
298
298
299 for i in range(len(ax.lines)):
299 for i in range(len(ax.lines)):
300 line = ax.lines[i]
300 line = ax.lines[i]
301 line.set_data(x[i,:],y)
301 line.set_data(x[i,:],y)
302
302
303 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
303 def createPmultilineYAxis(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='', legendlabels=None,
304 ticksize=9, xtick_visible=True, ytick_visible=True,
304 ticksize=9, xtick_visible=True, ytick_visible=True,
305 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
305 nxticks=4, nyticks=10, marker='.', markersize=10, linestyle="None",
306 grid=None, XAxisAsTime=False):
306 grid=None, XAxisAsTime=False):
307
307
308 """
308 """
309
309
310 Input:
310 Input:
311 grid : None, 'both', 'x', 'y'
311 grid : None, 'both', 'x', 'y'
312 """
312 """
313
313
314 matplotlib.pyplot.ioff()
314 matplotlib.pyplot.ioff()
315
315
316 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
316 # lines = ax.plot(x, y.T, marker=marker,markersize=markersize,linestyle=linestyle)
317 lines = ax.plot(x, y.T, linestyle='None', marker='.', markersize=markersize)
317 lines = ax.plot(x, y.T, linestyle='None', marker='.', markersize=markersize)
318 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
318 leg = ax.legend(lines, legendlabels, loc='upper left', bbox_to_anchor=(1.01, 1.00), numpoints=1, handlelength=1.5, \
319 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
319 handletextpad=0.5, borderpad=0.5, labelspacing=0.5, borderaxespad=0.)
320
320
321 for label in leg.get_texts(): label.set_fontsize(9)
321 for label in leg.get_texts(): label.set_fontsize(9)
322
322
323 ax.set_xlim([xmin,xmax])
323 ax.set_xlim([xmin,xmax])
324 ax.set_ylim([ymin,ymax])
324 ax.set_ylim([ymin,ymax])
325 printLabels(ax, xlabel, ylabel, title)
325 printLabels(ax, xlabel, ylabel, title)
326
326
327 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
327 # xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/(nxticks)) + int(xmin)
328 # ax.set_xticks(xtickspos)
328 # ax.set_xticks(xtickspos)
329
329
330 for tick in ax.get_xticklabels():
330 for tick in ax.get_xticklabels():
331 tick.set_visible(xtick_visible)
331 tick.set_visible(xtick_visible)
332
332
333 for tick in ax.xaxis.get_major_ticks():
333 for tick in ax.xaxis.get_major_ticks():
334 tick.label.set_fontsize(ticksize)
334 tick.label.set_fontsize(ticksize)
335
335
336 for tick in ax.get_yticklabels():
336 for tick in ax.get_yticklabels():
337 tick.set_visible(ytick_visible)
337 tick.set_visible(ytick_visible)
338
338
339 for tick in ax.yaxis.get_major_ticks():
339 for tick in ax.yaxis.get_major_ticks():
340 tick.label.set_fontsize(ticksize)
340 tick.label.set_fontsize(ticksize)
341
341
342 iplot = ax.lines[-1]
342 iplot = ax.lines[-1]
343
343
344 if '0.' in matplotlib.__version__[0:2]:
344 if '0.' in matplotlib.__version__[0:2]:
345 print "The matplotlib version has to be updated to 1.1 or newer"
345 print "The matplotlib version has to be updated to 1.1 or newer"
346 return iplot
346 return iplot
347
347
348 if '1.0.' in matplotlib.__version__[0:4]:
348 if '1.0.' in matplotlib.__version__[0:4]:
349 print "The matplotlib version has to be updated to 1.1 or newer"
349 print "The matplotlib version has to be updated to 1.1 or newer"
350 return iplot
350 return iplot
351
351
352 if grid != None:
352 if grid != None:
353 ax.grid(b=True, which='major', axis=grid)
353 ax.grid(b=True, which='major', axis=grid)
354
354
355 matplotlib.pyplot.tight_layout()
355 matplotlib.pyplot.tight_layout()
356
356
357 if XAxisAsTime:
357 if XAxisAsTime:
358
358
359 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
359 func = lambda x, pos: ('%s') %(datetime.datetime.utcfromtimestamp(x).strftime("%H:%M:%S"))
360 ax.xaxis.set_major_formatter(FuncFormatter(func))
360 ax.xaxis.set_major_formatter(FuncFormatter(func))
361 ax.xaxis.set_major_locator(LinearLocator(7))
361 ax.xaxis.set_major_locator(LinearLocator(7))
362
362
363 matplotlib.pyplot.ion()
363 matplotlib.pyplot.ion()
364
364
365 return iplot
365 return iplot
366
366
367 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
367 def pmultilineyaxis(iplot, x, y, xlabel='', ylabel='', title=''):
368
368
369 ax = iplot.get_axes()
369 ax = iplot.get_axes()
370
370
371 printLabels(ax, xlabel, ylabel, title)
371 printLabels(ax, xlabel, ylabel, title)
372
372
373 for i in range(len(ax.lines)):
373 for i in range(len(ax.lines)):
374 line = ax.lines[i]
374 line = ax.lines[i]
375 line.set_data(x,y[i,:])
375 line.set_data(x,y[i,:])
376
376
377 def draw(fig):
377 def draw(fig):
378
378
379 if type(fig) == 'int':
379 if type(fig) == 'int':
380 raise ValueError, "This parameter should be of tpye matplotlib figure"
380 raise ValueError, "This parameter should be of tpye matplotlib figure"
381
381
382 fig.canvas.draw() No newline at end of file
382 fig.canvas.draw()
General Comments 0
You need to be logged in to leave comments. Login now