Python matplotlib.transforms.BboxTransform() Examples

The following are 2 code examples of matplotlib.transforms.BboxTransform(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.transforms , or try the search function .
Example #1
Source File: SPLView.py    From pythonista-scripts with MIT License 5 votes vote down vote up
def convert_point(self,point_px, stop=False):
      '''
      given a touch point in the view space, compute the corresponding point in data coords. assumes linear scaling!
      TODO: support log scaling 
      
      there are basically two bbox transforms:  1) from figure coords to view coords, accounting for sign change in y. this then lets us compute axes box in view coords, and generate 2) transform from view to data coords.

      '''
      transFig=BboxTransformTo(Bbox([(0,self.height),(self.width,0)]))
      bbox_axes=Bbox(transFig.transform(plt.gca().get_position()))
      bbox_data=Bbox([(self.xlim[0],self.ylim[0]),(self.xlim[1],self.ylim[1])])
      transMPL=BboxTransform(bbox_axes,bbox_data)
      self.trans=transMPL
      ax_pt=transMPL.transform_point(point_px)      
      return ax_pt 
Example #2
Source File: MPLView.py    From pythonista-scripts with MIT License 5 votes vote down vote up
def convert_point(self,point_px, stop=False):
      '''
      given a touch point in the view space, compute the corresponding point in data coords. assumes linear scaling!
      TODO: support log scaling 
      
      there are basically two bbox transforms:  1) from figure coords to view coords, accounting for sign change in y. this then lets us compute axes box in view coords, and generate 2) transform from view to data coords.

      '''
      transFig=BboxTransformTo(Bbox([(0,self.height),(self.width,0)]))
      bbox_axes=Bbox(transFig.transform(plt.gca().get_position()))
      bbox_data=Bbox([(self.xlim[0],self.ylim[0]),(self.xlim[1],self.ylim[1])])
      transMPL=BboxTransform(bbox_axes,bbox_data)
      self.trans=transMPL
      ax_pt=transMPL.transform_point(point_px)      
      return ax_pt