def makeFigure(self, margin=0, default_aspect=1.3, **kw): kw['margin'] = margin kw['default_aspect'] = default_aspect (width, height), posn, kw = figureLayout(leftovers=True, **kw) fig = self._makeFigure(width, height) ax = fig.add_axes(posn, adjustable="datalim", frame_on=False, xticks=[], yticks=[]) g = self.populateAxes(ax, **kw) return fig
def comparison_display(seq1, seq2, left=.5, bottom=.5, **kw): """'Fat' annotated X and Y axes for a dotplot Returns a matplotlib axes object placed and scaled ready for plotting a sequence vs sequence comparison between the sequences (or alignments) seq1 and seq2, which are also displayed. The aspect ratio will depend on the sequence lengths as the sequences are drawn to the same scale""" import matplotlib.pyplot as plt (x1, y1, w1, h1) = _reinchify( *seq1.figureLayout(labeled=True, bottom=bottom, margin=0)) (x2, y2, w2, h2) = _reinchify(*seq2.figureLayout(labeled=False, bottom=left, margin=0)) # equalize points-per-base scales to get aspect ratio 1.0 ipb = min(w1 / len(seq1), w2 / len(seq2)) (w1, w2) = ipb * len(seq1), ipb * len(seq2) # Figure with correct aspect # Indent enough for labels and/or vertical display (w, h), posn = figureLayout(width=w1, height=w2, left=max(x1, y2 + h2), bottom=y1 + h1, **kw) fig = plt.figure(figsize=(w, h), facecolor='white') fw = fig.get_figwidth() fh = fig.get_figheight() # 2 sequence display axes x = seq1.asAxes(fig, [posn[0], posn[1] - h1 / fh, posn[2], h1 / fh]) y = seq2.asAxes(fig, [posn[0] - h2 / fw, posn[1], h2 / fw, posn[3]], vertical=True, labeled=False) # and 1 dotplot axes d = fig.add_axes(posn, sharex=x, sharey=y) d.xaxis.set_visible(False) d.yaxis.set_visible(False) return d
def comparison_display(seq1, seq2, left=.5, bottom=.5, **kw): """'Fat' annotated X and Y axes for a dotplot Returns a matplotlib axes object placed and scaled ready for plotting a sequence vs sequence comparison between the sequences (or alignments) seq1 and seq2, which are also displayed. The aspect ratio will depend on the sequence lengths as the sequences are drawn to the same scale""" import matplotlib.pyplot as plt (x1, y1, w1, h1) = _reinchify(*seq1.figureLayout( labeled=True, bottom=bottom, margin=0)) (x2, y2, w2, h2) = _reinchify(*seq2.figureLayout( labeled=False, bottom=left, margin=0)) # equalize points-per-base scales to get aspect ratio 1.0 ipb = min(w1/len(seq1), w2/len(seq2)) (w1, w2) = ipb*len(seq1), ipb*len(seq2) # Figure with correct aspect # Indent enough for labels and/or vertical display (w,h), posn = figureLayout(width=w1, height=w2, left=max(x1,y2+h2), bottom=y1+h1, **kw) fig = plt.figure(figsize=(w,h), facecolor='white') fw = fig.get_figwidth() fh = fig.get_figheight() # 2 sequence display axes x = seq1.asAxes(fig, [posn[0], posn[1]-h1/fh, posn[2], h1/fh]) y = seq2.asAxes(fig, [posn[0]-h2/fw, posn[1], h2/fw, posn[3]], vertical=True, labeled=False) # and 1 dotplot axes d = fig.add_axes(posn, sharex=x, sharey=y) d.xaxis.set_visible(False) d.yaxis.set_visible(False) return d