loc is a string or an integer specifying the legend location. The valid location codes are:: 'upper right' : 1, 'upper left' : 2, 'lower left' : 3, 'lower right' : 4, 'right' : 5, (same as 'center right', for back-compatibility)
(self, loc,
pad=0.4, borderpad=0.5,
child=None, prop=None, frameon=True,
bbox_to_anchor=None,
bbox_transform=None,
**kwargs)
| 987 | } |
| 988 | |
| 989 | def __init__(self, loc, |
| 990 | pad=0.4, borderpad=0.5, |
| 991 | child=None, prop=None, frameon=True, |
| 992 | bbox_to_anchor=None, |
| 993 | bbox_transform=None, |
| 994 | **kwargs): |
| 995 | """ |
| 996 | loc is a string or an integer specifying the legend location. |
| 997 | The valid location codes are:: |
| 998 | |
| 999 | 'upper right' : 1, |
| 1000 | 'upper left' : 2, |
| 1001 | 'lower left' : 3, |
| 1002 | 'lower right' : 4, |
| 1003 | 'right' : 5, (same as 'center right', for back-compatibility) |
| 1004 | 'center left' : 6, |
| 1005 | 'center right' : 7, |
| 1006 | 'lower center' : 8, |
| 1007 | 'upper center' : 9, |
| 1008 | 'center' : 10, |
| 1009 | |
| 1010 | pad : pad around the child for drawing a frame. given in |
| 1011 | fraction of fontsize. |
| 1012 | |
| 1013 | borderpad : pad between offsetbox frame and the bbox_to_anchor, |
| 1014 | |
| 1015 | child : OffsetBox instance that will be anchored. |
| 1016 | |
| 1017 | prop : font property. This is only used as a reference for paddings. |
| 1018 | |
| 1019 | frameon : draw a frame box if True. |
| 1020 | |
| 1021 | bbox_to_anchor : bbox to anchor. Use self.axes.bbox if None. |
| 1022 | |
| 1023 | bbox_transform : with which the bbox_to_anchor will be transformed. |
| 1024 | |
| 1025 | """ |
| 1026 | super().__init__(**kwargs) |
| 1027 | |
| 1028 | self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform) |
| 1029 | self.set_child(child) |
| 1030 | |
| 1031 | if isinstance(loc, str): |
| 1032 | try: |
| 1033 | loc = self.codes[loc] |
| 1034 | except KeyError: |
| 1035 | raise ValueError('Unrecognized location "%s". Valid ' |
| 1036 | 'locations are\n\t%s\n' |
| 1037 | % (loc, '\n\t'.join(self.codes))) |
| 1038 | |
| 1039 | self.loc = loc |
| 1040 | self.borderpad = borderpad |
| 1041 | self.pad = pad |
| 1042 | |
| 1043 | if prop is None: |
| 1044 | self.prop = FontProperties(size=rcParams["legend.fontsize"]) |
| 1045 | elif isinstance(prop, dict): |
| 1046 | self.prop = FontProperties(**prop) |
nothing calls this directly
no test coverage detected