''' Vectorizing alg '''
from numpy import sqrt,sin,arange
from math import pi
import matplotlib.pyplot as plt
x = arange(0.0, 1.001*pi, 0.01*pi)
y = sqrt(x)*sin(x)
print(y)
plt.plot(x,y)
plt.show()

















































''' Plotting with matplotlib.pyplot 
    plots sine and cosine functions'''
import matplotlib.pyplot as plt
from numpy import arange,sin,cos

x = arange(0.0,6.2,0.2)
plt.plot(x,sin(x),'o-',x,cos(x),'^-') # Plot with specified
                                      # line and marker style
plt.xlabel('x')                       # Add label to x-axis
plt.legend(('sine','cosine'),loc = 0) # Add legend in loc. 3
plt.grid(True)                        # Add coordinate grid
plt.savefig('testplot.png',format='png') # Save plot in png
                                         # format for future use
plt.show()                            # Show plot on screen          

# more than one plot in a figure
plt.subplot(2,1,1)
plt.plot(x,sin(x),'o-')
plt.xlabel('x');plt.ylabel('sin(x)')
plt.grid(True)
plt.subplot(2,1,2)
plt.plot(x,cos(x),'^-')
plt.xlabel('x');plt.ylabel('cos(x)')
plt.grid(True)
plt.show()
























## module error
''' err(string).
    Prints 'string' and terminates program.
'''    
import sys
def err(string):
    print(string)
    input('Press return to exit')
    sys.exit(0)

# >>> import error
# >>> print(error.__doc__)