def mosaic(data, index=None, ax=None, horizontal=True, gap=0.005, properties=(lambda key: None), labelizer=None, title='', statistic=False, axes_label=True, label_rotation=0.0):
 if (isinstance(data, DataFrame) and (index is None)):
  raise ValueError('You must pass an index if data is a DataFrame. See examples.')
 from matplotlib.patches import Rectangle
 (fig, ax) = utils.create_mpl_ax(ax)
 data = _normalize_data(data, index)
 rects = _hierarchical_split(data, horizontal=horizontal, gap=gap)
 if (labelizer is None):
  labelizer = (lambda k: '\n'.join(k))
 if statistic:
  default_props = _statistical_coloring(data)
 else:
  default_props = _create_default_properties(data)
 if isinstance(properties, dict):
  color_dict = properties
  properties = (lambda key: color_dict.get(key, None))
 for (k, v) in iteritems(rects):
  (x, y, w, h) = v
  conf = properties(k)
  props = (conf if conf else default_props[k])
  text = labelizer(k)
  Rect = Rectangle((x, y), w, h, label=text, **props)
  ax.add_patch(Rect)
  ax.text((x + (w / 2)), (y + (h / 2)), text, ha='center', va='center', size='smaller')
 if axes_label:
  if np.iterable(label_rotation):
   rotation = label_rotation
  else:
   rotation = ([label_rotation] * 4)
  labels = _create_labels(rects, horizontal, ax, rotation)
 else:
  ax.set_xticks([])
  ax.set_xticklabels([])
  ax.set_yticks([])
  ax.set_yticklabels([])
 ax.set_title(title)
 return (fig, rects)

def mosaic ( data , index = None , ax = None , horizontal = True , gap = 0.005 , properties = ( lambda key : None ) , labelizer = None , title = '' , statistic = False , axes_label = True , label_rotation = 0.0 ) : if ( isinstance ( data , DataFrame ) and ( index is None ) ) : raise ValueError ( 'You must pass an index if data is a DataFrame. See examples.' ) from matplotlib . patches import Rectangle ( fig , ax ) = utils . create_mpl_ax ( ax ) data = _normalize_data ( data , index ) rects = _hierarchical_split ( data , horizontal = horizontal , gap = gap ) if ( labelizer is None ) : labelizer = ( lambda k : '\n' . join ( k ) ) if statistic : default_props = _statistical_coloring ( data ) else : default_props = _create_default_properties ( data ) if isinstance ( properties , dict ) : color_dict = properties properties = ( lambda key : color_dict . get ( key , None ) ) for ( k , v ) in iteritems ( rects ) : ( x , y , w , h ) = v conf = properties ( k ) props = ( conf if conf else default_props [ k ] ) text = labelizer ( k ) Rect = Rectangle ( ( x , y ) , w , h , label = text , ** props ) ax . add_patch ( Rect ) ax . text ( ( x + ( w / 2 ) ) , ( y + ( h / 2 ) ) , text , ha = 'center' , va = 'center' , size = 'smaller' ) if axes_label : if np . iterable ( label_rotation ) : rotation = label_rotation else : rotation = ( [ label_rotation ] * 4 ) labels = _create_labels ( rects , horizontal , ax , rotation ) else : ax . set_xticks ( [ ] ) ax . set_xticklabels ( [ ] ) ax . set_yticks ( [ ] ) ax . set_yticklabels ( [ ] ) ax . set_title ( title ) return ( fig , rects )
make a grid from images .