from numpy import *
from matplotlib.pyplot import *

# google matplotlib gallery

# create basepoints and function values
x = linspace(-2., 2., 100)
y = (x + 2.)**2 - 5.
fig = figure() # create figure
ax = fig.add_subplot(1,1,1) # subplot with 1 row, 1 column, and get axes of first plot
ax.plot(x,y)

ax.set_xlabel('x values')
ax.set_ylabel('y values')
ax.set_title('quadratic function')

show() # show plot

fig.savefig( "test.pdf" )  # saves plot into file