text: import matplotlib.pyplot as plt
  import matplotlib.gridspec as gridspec
  import numpy as np
  
  def panel(images, gspec, **kargs):
  	M, N = gspec
  
  	x, y = (1024, 512) if 'dims' not in kargs else kargs['dims']
  	dpi = 72 if 'dpi' not in kargs else kargs['dpi']
  	texts = [] if 'texts' not in kargs else kargs['texts']
  	tx, ty = (10, 10) if 'text_pos' not in kargs else kargs['text_pos']
  	tc = 'white' if 'text_color' not in kargs else kargs['text_color']
  	ts = 12 if 'text_size' not in kargs else kargs['text_size']
  	interval = [0, 255] if 'interval' not in kargs else kargs['interval']
  
  	fig = plt.figure(figsize=(x/dpi, y/dpi))
  	gs = gridspec.GridSpec(N, M)
  	gs.update(	left=0, right=1,
                  bottom=0, top=1,
                  wspace=0, hspace=0)
  	images = (images - interval[0])/(interval[1] - interval[0])
  	images[images < 0] = 0
  	images[images > 1] = 1
  	for n in range(N):
  		for m in range(M):
  			ax = plt.subplot(gs[n, m])
  			ax.axis('off')
  			try:
  				image = images[n*M + m]
  			except:
  				image = images[0]*0
  			if image.ndim == 2:
  				ax.imshow(image, cmap='gray')
  			else:
  				ax.imshow(image)
  			try:
  				texto = texts[n*M + m]
  			except:
  				texto = ''
  			ax.text(	tx, ty, texto,
  						color=tc, size=ts,
  						horizontalalignment='left',
  						verticalalignment='top')
  	plt.show()