def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
 if (fig is None):
  fig = gcf()
 (s1, s2) = shape
 subplotspec = GridSpec(s1, s2).new_subplotspec(loc, rowspan=rowspan, colspan=colspan)
 a = fig.add_subplot(subplotspec, **kwargs)
 bbox = a.bbox
 byebye = []
 for other in fig.axes:
  if (other == a):
   continue
  if bbox.fully_overlaps(other.bbox):
   byebye.append(other)
 for ax in byebye:
  delaxes(ax)
 return a

def subplot2grid ( shape , loc , rowspan = 1 , colspan = 1 , fig = None , ** kwargs ) : if ( fig is None ) : fig = gcf ( ) ( s1 , s2 ) = shape subplotspec = GridSpec ( s1 , s2 ) . new_subplotspec ( loc , rowspan = rowspan , colspan = colspan ) a = fig . add_subplot ( subplotspec , ** kwargs ) bbox = a . bbox byebye = [ ] for other in fig . axes : if ( other == a ) : continue if bbox . fully_overlaps ( other . bbox ) : byebye . append ( other ) for ax in byebye : delaxes ( ax ) return a
create a subplot in a grid .