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

Method set_location

lib/matplotlib/axes/_secondary_axes.py:80–142  ·  view source on GitHub ↗

Set the vertical or horizontal location of the axes in parent-normalized coordinates. Parameters ---------- location : {'top', 'bottom', 'left', 'right'} or float The position to put the secondary axis. Strings can be 'top' or 'botto

(self, location, transform=None)

Source from the content-addressed store, hash-verified

78 self._axis.set_label_position(align)
79
80 def set_location(self, location, transform=None):
81 """
82 Set the vertical or horizontal location of the axes in
83 parent-normalized coordinates.
84
85 Parameters
86 ----------
87 location : {'top', 'bottom', 'left', 'right'} or float
88 The position to put the secondary axis. Strings can be 'top' or
89 'bottom' for orientation='x' and 'right' or 'left' for
90 orientation='y'. A float indicates the relative position on the
91 parent Axes to put the new Axes, 0.0 being the bottom (or left)
92 and 1.0 being the top (or right).
93
94 transform : `.Transform`, optional
95 Transform for the location to use. Defaults to
96 the parent's ``transAxes``, so locations are normally relative to
97 the parent axes.
98
99 .. versionadded:: 3.9
100 """
101
102 _api.check_isinstance((transforms.Transform, None), transform=transform)
103
104 # This puts the rectangle into figure-relative coordinates.
105 if isinstance(location, str):
106 _api.check_in_list(self._locstrings, location=location)
107 self._pos = 1. if location in ('top', 'right') else 0.
108 elif isinstance(location, numbers.Real):
109 self._pos = location
110 else:
111 raise ValueError(
112 f"location must be {self._locstrings[0]!r}, "
113 f"{self._locstrings[1]!r}, or a float, not {location!r}")
114
115 self._loc = location
116
117 if self._orientation == 'x':
118 # An x-secondary axes is like an inset axes from x = 0 to x = 1 and
119 # from y = pos to y = pos + eps, in the parent's transAxes coords.
120 bounds = [0, self._pos, 1., 1e-10]
121
122 # If a transformation is provided, use its y component rather than
123 # the parent's transAxes. This can be used to place axes in the data
124 # coords, for instance.
125 if transform is not None:
126 transform = transforms.blended_transform_factory(
127 self._parent.transAxes, transform)
128 else: # 'y'
129 bounds = [self._pos, 0, 1e-10, 1]
130 if transform is not None:
131 transform = transforms.blended_transform_factory(
132 transform, self._parent.transAxes) # Use provided x axis
133
134 # If no transform is provided, use the parent's transAxes
135 if transform is None:
136 transform = self._parent.transAxes
137

Callers 1

__init__Method · 0.95

Calls 2

set_axes_locatorMethod · 0.45

Tested by

no test coverage detected