#############################################
# A SIMPLE DEMO OF PLOT USING PYLAB MODULE  #   
#############################################

# IMPORT THE MODULE
from pylab import *

# CREATE AN ARRAY FOR X
x = arange(0, 2, 0.01)
# CREATE ARRAYS FOR Y
f = sin(2 * pi * x)
y = f + randn(len(f))

# PLOTTING 2 SERIES ON THE GRAPH
plot(x, f, 'b-', x, y, 'ro', lw = 2)
# PUT THE GRID LINE
grid(True)
# PUT THE TITLE
title('My First Plot by Python')
# SPECIFY LIMITS OF X-AXIS AND Y-AXIS
xlim(0, 2)
ylim(-4, 4)
# PUT LABELS OF X-AXIS AND Y-AXIS
xlabel('X')
ylabel('Function(X)')
# PUT THE LEGEND
legend(('True Function', 'Observations'), loc = 'lower right', shadow = True)
# PUT SOME TEXTS WITHIN THE GRAPH
text(0.1, 3, r'$Y = sin(2\pi X)$', fontsize = 20, color = 'k')

show()
