""" GIF test *** Need to install images2gif, Figtodat From Sukhbinder Singh @ https://sukhbinder.wordpress.com/2014/03/19/gif-animation-in-python-in-3-steps/ """ import Figtodat from images2gif import writeGif import matplotlib.pyplot as plt import numpy figure = plt.figure() plot = figure.add_subplot(111) plot.hold(False) # draw a cardinal sine plot images = [] y = numpy.random.randn(100, 5) for i in range(y.shape[1]): plot.plot(numpy.sin(y[:, i])) plot.set_ylim(-3.0, 3) plot.text(90, -2.5, str(i)) im = Figtodat.fig2img(figure) images.append(im) writeGif("images.gif", images, duration=0.3, dither=0)
sub.yaxis.label.set_color('white') sub.xaxis.label.set_color('white') sub.tick_params(axis='x', colors='white') sub.tick_params(axis='y', colors='white') sub.tick_params(axis='both', direction='out') sub.get_xaxis().tick_bottom() sub.get_yaxis().tick_left() sub.set_title('HR Trajectory for '+str(m)+'M star') sub.set_ylabel('Luminosity (log LS)') sub.set_xlabel('Temperature (log K)') sub.set_ylim(min(logL)-0.05, max(logL)+0.05) sub.set_xlim(max(np.log10(Teff))+0.2, min(np.log10(Teff))-0.2) x0,x1 = sub.get_xlim() y0,y1 = sub.get_ylim() HR = Figtodat.fig2img(fig).resize(tuple(isize)) HR = HR.filter(ImageFilter.EDGE_ENHANCE) #make blank image omage = Image.new("RGB", bsize) #inscribe text draw = ImageDraw.Draw(omage) draw.text((10,10),'BEC sim',(255,255,255)) draw.text((10,30),'STAR '+str(m)+'M',(255,255,255)) w, h = draw.textsize(('%.2f' % t[int(i*len(t)/O)])+'y') draw.text((isize[0]-w-10,10),('%.2f' % t[int(i*len(t)/O)])+'y',(255,255,255)) w, h = draw.textsize('d'+('%.2f' % dt)+'y') draw.text((isize[0]-w-10,30),'d'+('%.2f' % dt)+'y',(255,255,255)) draw = ImageDraw.Draw(omage) draw = ImageDraw.Draw(omage) #paste star image
# -*- coding: utf-8 -*- """ Created on Fri Mar 14 08:34:48 2014 @author: Sukhbinder Singh """ import Figtodat from images2gif import writeGif import matplotlib.pyplot as plt import numpy figure = plt.figure() plot = figure.add_subplot(111) plot.hold(False) # draw a cardinal sine plot images = [] y = numpy.random.randn(100, 5) for i in range(y.shape[1]): plot.plot(numpy.sin(y[:, i])) plot.set_ylim(-3.0, 3) plot.text(90, -2.5, str(i)) im = Figtodat.fig2img(figure) images.append(im) writeGif("images.gif", images, duration=0.3, dither=0)