MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / AnchoredOffsetbox

Class AnchoredOffsetbox

lib/matplotlib/offsetbox.py:908–1100  ·  view source on GitHub ↗

An OffsetBox placed according to location *loc*. AnchoredOffsetbox has a single child. When multiple children are needed, use an extra OffsetBox to enclose them. By default, the offset box is anchored against its parent Axes. You may explicitly specify the *bbox_to_anchor*.

Source from the content-addressed store, hash-verified

906
907
908class AnchoredOffsetbox(OffsetBox):
909 """
910 An OffsetBox placed according to location *loc*.
911
912 AnchoredOffsetbox has a single child. When multiple children are needed,
913 use an extra OffsetBox to enclose them. By default, the offset box is
914 anchored against its parent Axes. You may explicitly specify the
915 *bbox_to_anchor*.
916 """
917 zorder = 5 # zorder of the legend
918
919 # Location codes
920 codes = {'upper right': 1,
921 'upper left': 2,
922 'lower left': 3,
923 'lower right': 4,
924 'right': 5,
925 'center left': 6,
926 'center right': 7,
927 'lower center': 8,
928 'upper center': 9,
929 'center': 10,
930 }
931
932 def __init__(self, loc, *,
933 pad=0.4, borderpad=0.5,
934 child=None, prop=None, frameon=True,
935 bbox_to_anchor=None,
936 bbox_transform=None,
937 **kwargs):
938 """
939 Parameters
940 ----------
941 loc : str
942 The box location. Valid locations are
943 'upper left', 'upper center', 'upper right',
944 'center left', 'center', 'center right',
945 'lower left', 'lower center', 'lower right'.
946 For backward compatibility, numeric values are accepted as well.
947 See the parameter *loc* of `.Legend` for details.
948 pad : float, default: 0.4
949 Padding around the child as fraction of the fontsize.
950 borderpad : float or (float, float), default: 0.5
951 Padding between the offsetbox frame and the *bbox_to_anchor*.
952 If a float, the same padding is used for both x and y.
953 If a tuple of two floats, it specifies the (x, y) padding.
954
955 .. versionadded:: 3.11
956 The *borderpad* parameter now accepts a tuple of (x, y) paddings.
957 child : `.OffsetBox`
958 The box that will be anchored.
959 prop : `.FontProperties`
960 This is only used as a reference for paddings. If not given,
961 :rc:`legend.fontsize` is used.
962 frameon : bool
963 Whether to draw a frame around the box.
964 bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
965 Box that is used to position the legend in conjunction with *loc*.

Callers 12

plot_pathsFunction · 0.90
add_offsetboxesFunction · 0.90
test_offsetbox_clippingFunction · 0.90
test_offsetbox_loc_codesFunction · 0.90
test_paddedboxFunction · 0.90
annotations.pyFile · 0.90
demo_text_path.pyFile · 0.90
draw_textFunction · 0.90
draw_circlesFunction · 0.90
draw_ellipseFunction · 0.90
draw_sizebarFunction · 0.90

Calls

no outgoing calls

Tested by 6

plot_pathsFunction · 0.72
add_offsetboxesFunction · 0.72
test_offsetbox_clippingFunction · 0.72
test_offsetbox_loc_codesFunction · 0.72
test_paddedboxFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…