Post date: Aug 30, 2012 2:05:18 AM
Just make sure that you
pylab.show() to show the plotted figure.Here is the code snippet that works in both Eclipse and Python IDLE:
import numpy as npimport matplotlib.pyplot as pltimport pylab# Come up with x and yx = np.arange(0, 5, 0.1)y = np.sin(x)# Just print x and y for funprint xprint y# plot the x and y and you are supposed to see a sine curveplt.plot(x, y)# without the line below, the figure won't showpylab.show()The code above should give you something like this
Another code you might want to try is this:
from numpy import *a = arange(15).reshape(3, 5)print "The matrix a is \n"+str(a)print "a[1,2] = " +str(a[1,2])print "the matrix dimension is " + str(a.shape)from matplotlib.pyplot import *from pylab import *matshow(a)show()and you are going to see this image: