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

Method set_anchor

lib/matplotlib/axes/_base.py:1905–1949  ·  view source on GitHub ↗

Define the anchor location. The actual drawing area (active position) of the Axes may be smaller than the Bbox (original position) when a fixed aspect is required. The anchor defines where the drawing area will be located within the available space.

(self, anchor, share=False)

Source from the content-addressed store, hash-verified

1903 return self._anchor
1904
1905 def set_anchor(self, anchor, share=False):
1906 """
1907 Define the anchor location.
1908
1909 The actual drawing area (active position) of the Axes may be smaller
1910 than the Bbox (original position) when a fixed aspect is required. The
1911 anchor defines where the drawing area will be located within the
1912 available space.
1913
1914 Parameters
1915 ----------
1916 anchor : (float, float) or {'C', 'SW', 'S', 'SE', 'E', 'NE', ...}
1917 Either an (*x*, *y*) pair of relative coordinates (0 is left or
1918 bottom, 1 is right or top), 'C' (center), or a cardinal direction
1919 ('SW', southwest, is bottom left, etc.). str inputs are shorthands
1920 for (*x*, *y*) coordinates, as shown in the following diagram::
1921
1922 ┌─────────────────┬─────────────────┬─────────────────┐
1923'NW' (0.0, 1.0) │ 'N' (0.5, 1.0) │ 'NE' (1.0, 1.0) │
1924 ├─────────────────┼─────────────────┼─────────────────┤
1925'W' (0.0, 0.5) │ 'C' (0.5, 0.5) │ 'E' (1.0, 0.5) │
1926 ├─────────────────┼─────────────────┼─────────────────┤
1927'SW' (0.0, 0.0) │ 'S' (0.5, 0.0) │ 'SE' (1.0, 0.0) │
1928 └─────────────────┴─────────────────┴─────────────────┘
1929
1930 share : bool, default: False
1931 If ``True``, apply the settings to all shared Axes.
1932
1933 See Also
1934 --------
1935 matplotlib.axes.Axes.set_aspect
1936 for a description of aspect handling.
1937 """
1938 if not (anchor in mtransforms.Bbox.coefs or len(anchor) == 2):
1939 raise ValueError('argument must be among %s' %
1940 ', '.join(mtransforms.Bbox.coefs))
1941 if share:
1942 axes = {sibling for name in self._axis_names
1943 for sibling in self._shared_axes[name].get_siblings(self)}
1944 else:
1945 axes = [self]
1946 for ax in axes:
1947 ax._anchor = anchor
1948
1949 self.stale = True
1950
1951 def get_data_ratio(self):
1952 """

Callers 6

set_aspectMethod · 0.95
reposition_colorbarFunction · 0.45
make_axesFunction · 0.45
make_axes_gridspecFunction · 0.45
test_axis_method_errorsFunction · 0.45

Calls 2

joinMethod · 0.80
get_siblingsMethod · 0.45

Tested by 1

test_axis_method_errorsFunction · 0.36