def _set_transform(self): ax = self.ax if self.units in ('x', 'y'): if self.units == 'x': dx0 = ax.viewLim.ur().x() - ax.viewLim.ll().x() dx1 = ax.bbox.ur().x() - ax.bbox.ll().x() else: dx0 = ax.viewLim.ur().y() - ax.viewLim.ll().y() dx1 = ax.bbox.ur().y() - ax.bbox.ll().y() dx = dx1/dx0 else: if self.units == 'width': dx = ax.bbox.ur().x() - ax.bbox.ll().x() elif self.units == 'height': dx = ax.bbox.ur().y() - ax.bbox.ll().y() elif self.units == 'dots': dx = T.Value(1) elif self.units == 'inches': dx = ax.figure.dpi else: raise ValueError('unrecognized units') bb = T.Bbox(T.origin(), T.Point(dx, dx)) trans = T.get_bbox_transform(T.unit_bbox(), bb) self.set_transform(trans) return trans
def _set_transform(self): if self.coord == 'data': self.set_transform(self.Q.ax.transData) elif self.coord == 'axes': self.set_transform(self.Q.ax.transAxes) elif self.coord == 'figure': self.set_transform(self.Q.ax.figure.transFigure) elif self.coord == 'inches': dx = ax.figure.dpi bb = T.Bbox(T.origin(), T.Point(dx, dx)) trans = T.get_bbox_transform(T.unit_bbox(), bb) self.set_transform(trans) else: raise ValueError('unrecognized coordinates')