In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np

In [2]:
img = mpimg.imread('chameleon.png')[:,:,1]

In [3]:
imgplot = plt.imshow(img)
plt.colorbar()


Out[3]:
<matplotlib.colorbar.Colorbar at 0x7f61cbd42dd0>

In [4]:
plt.imshow(img, cmap="hot")
plt.colorbar()


Out[4]:
<matplotlib.colorbar.Colorbar at 0x7f61ca337a50>

In [5]:
plt.hist(img.ravel(), bins=256, range=(0.0, 1.), fc='k', ec='k');



In [6]:
imgplot = plt.imshow(img, clim=(0.5,0.7))
plt.colorbar()


Out[6]:
<matplotlib.colorbar.Colorbar at 0x7f61c9b72390>

In [7]:
from PIL import Image

In [8]:
img = Image.open('chameleon.png')

In [18]:
plt.subplot(141)
plt.imshow(img)
img.thumbnail((64, 64), Image.ANTIALIAS)
plt.subplot(142)
plt.imshow(img)
plt.subplot(143)
plt.imshow(img, interpolation='nearest')
plt.subplot(144)
plt.imshow(img, interpolation='bicubic')


Out[18]:
<matplotlib.image.AxesImage at 0x7f61c9c8f4d0>

In [21]:
ax = plt.subplot2grid((2,2),(0,0))



In [23]:
ax2 = plt.subplot2grid((3,3),(1,0),colspan=2)
ax3 = plt.subplot2grid((3,3),(1,2),rowspan=2)



In [24]:
ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3)
ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)
ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
ax4 = plt.subplot2grid((3, 3), (2, 0))
ax5 = plt.subplot2grid((3, 3), (2, 1))



In [32]:
import matplotlib.gridspec as gridspec

gs = gridspec.GridSpec(3,3)
ax = plt.subplot(gs[0,0])
ax2 = plt.subplot(gs[1,:-1])
ax3 = plt.subplot(gs[1,-1])



In [37]:
gs = gridspec.GridSpec(3,3)
ax1 = plt.subplot(gs[0,:])
ax2 = plt.subplot(gs[1,:-1])
ax3 = plt.subplot(gs[1:,-1])
ax4 = plt.subplot(gs[2,0])
ax5 = plt.subplot(gs[2,1])



In [ ]: