lec6_pylab_review

lec6_pylab_review - #y=3.0*x**2-10.0*x+3.0 # ##x and y are...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
from pylab import * #-------SLIDE 1 --------- #generate a 2D Mesh: x=linspace(-np.pi,np.pi,30) y=linspace(-np.pi,np.pi,30) x,y=meshgrid(x,y) U=sin(y) #x-compo?nent of vector field V=cos(x) #y-component of vector field quiver(x,y,U,V,color='b') #colorcode arrows by magnitude quiver(x,y,U,V,sqrt(U**2+V**2)) show() #-----------SLIDE 6--------------- #data = np.loadtxt('data.dat') #x=data[:,0] #y=data[:,1] #plot(x,y,'go', label='My data') #legend(loc=(1.5,10.5)) #xlabel('Time (years)') #ylabel('Population') #show() #-----SLIDE 7---------------- #Download remote copy #import urllib #urllib.urlretrieve('http://www.phy.olemiss.edu/~jgladden/nopost/remotedata.dat', # filename='mylocaldata.dat') # #T,E,G=np.loadtxt('mylocaldata.dat',unpack=True) # #subplot(211) #plot(T,E,'g-^',ms=7) #ylabel('Young\'s Modulus (GPa)') #subplot(212) #plot(T,G,'b-^',ms=7) #ylabel('Shear Modulus (GPa)') #xlabel('Temperature (C)') #------------SLIDE 8------------ #x=linspace(0,10)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #y=3.0*x**2-10.0*x+3.0 # ##x and y are ROW arrays #XY=np.array([x,y]) ##convert XY to COLUMN arrays for output in columns, not rows #XYt=XY.transpose() #np.savetxt('mydata.txt',XYt,fmt='%2.3e',delimiter = '\t') #---------SLIDE 12---------------#print '-'*20,'a is an list', '-'*20 #def funct(a): # for i in range(len(a)): # a[i]=a[i]**2 # print 'Inside function: a=', a # return #a=[1,2,3,4] #print 'Outside function: a=', a #funct(a) #print 'Outside function: a=', a # #print '-'*20,'a is an array', '-'*20 #def funct(a): # a[0]=2 # print 'Inside function: a=', a # return #a=array([1,2,3,4]) #print 'Outside function: a=', a #funct(a) #print 'Outside function: a=', a # #print '-'*20,'a is an array', '-'*20 #def funct(a): # a=a**2 # print 'Inside function: a=', a # return #a=array([1,2,3,4]) #print 'Outside function: a=', a #funct(a) #print 'Outside function: a=', a...
View Full Document

This note was uploaded on 10/05/2010 for the course PHYS phy503 taught by Professor Gladden during the Spring '09 term at Ole Miss.

Page1 / 2

lec6_pylab_review - #y=3.0*x**2-10.0*x+3.0 # ##x and y are...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online