In [1]:
import pylab as pl
In [2]:
x = pl.linspace(-5,5,101)
In [3]:
y = sin(x)
In [4]:
pl.plot(x,y)
Out[4]:
[<matplotlib.lines.Line2D at 0xa41fe2c>]
In [5]:
a = 3
b = 4
c = 5
In [6]:
a
Out[6]:
3
In [8]:
pl.plot(x, y, "r-", x, pl.cos(x), "g.")
Out[8]:
[<matplotlib.lines.Line2D at 0xa648b6c>,
 <matplotlib.lines.Line2D at 0xa67646c>]
In [10]:
z = pl.identity(10)
In [11]:
z
Out[11]:
array([[ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.]])
In [12]:
pl.imshow(z)
Out[12]:
<matplotlib.image.AxesImage at 0xa851fec>
In [25]:
x = pl.linspace(-5,5,201)
y = pl.linspace(-7,7,201)[:, pl.newaxis]
In [26]:
z = pl.sin(x**2 + y**2)
In [28]:
pl.imshow(z)
Out[28]:
<matplotlib.image.AxesImage at 0xabb694c>
In [30]:
import pylab as pl
pl.figure(1, figsize=(6,6))
ax = pl.axes([0.1, 0.1, 0.8, 0.8])
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
fracs = [150,30,45, 10]
explode = (0, 0.05, 0, 0)
pl.pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True)
pl.title('Raining Hogs and Dogs', bbox={'facecolor':'0.8', 'pad':5})
pl.show()
In [32]:
chaine = "flf-----fdsafsda----21341221----dsa"
In [33]:
chaine.split("----")
Out[33]:
['flf', '-fdsafsda', '21341221', 'dsa']
In []: