Apr 25, 2013

Matplotlib basic plotting

In : x=np.arange(0,5,0.2)

In : y=np.sin(x)

In : plt.plot(x,y)



# Clears the current figure
In : plt.clf()

In : plt.plot(x,y, color='green', linewidth=3.0,linestyle='-')

# To save the plot
In : plt.savefig("a.png", dpi=72)


In [80]: x
Out[80]: array([1, 2, 3, 4, 5, 6, 7, 8, 9])

In [81]: y=x**2

In [94]: plt.plot(x,y, "ro")



In [98]: plt.plot(x,y, "bx")

In [119]: x=np.arange(0,5,0.2)

In [120]: plt.plot(x,x,'r-', x, x**2, 'bs', t, t**3, 'g^')
References: