示例#1
0
def clone_patch(patch: mpatches.Patch) -> mpatches.Patch:
    """ clone a patch element with the same properties as the given patch """
    if isinstance(patch, mpatches.Rectangle):
        return mpatches.Rectangle(xy=patch.get_xy(),
                                  width=patch.get_width(),
                                  height=patch.get_height())
    if isinstance(patch, mpatches.Circle):
        return mpatches.Circle(xy=patch.get_xy(), radius=patch.get_radius())
    if isinstance(patch, mpatches.Ellipse):
        return mpatches.Ellipse(xy=patch.get_xy(),
                                width=patch.get_width(),
                                height=patch.get_height())
    if isinstance(patch, mpatches.PathPatch):
        return mpatches.PathPatch(patch.get_path())
示例#2
0
 def get_vals(p: Patch) -> PosVal:
     value = p.get_width()
     div = 2 if centered else 1
     pos = (
         p.get_x() + p.get_width() / div,
         p.get_y() + p.get_height() / 2,
     )
     return value, pos