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

Method __call__

lib/matplotlib/colorbar.py:157–189  ·  view source on GitHub ↗
(self, ax, renderer)

Source from the content-addressed store, hash-verified

155 self._orig_locator = cbar.ax._axes_locator
156
157 def __call__(self, ax, renderer):
158 if self._orig_locator is not None:
159 pos = self._orig_locator(ax, renderer)
160 else:
161 pos = ax.get_position(original=True)
162 if self._cbar.extend == 'neither':
163 return pos
164
165 y, extendlen = self._cbar._proportional_y()
166 if not self._cbar._extend_lower():
167 extendlen[0] = 0
168 if not self._cbar._extend_upper():
169 extendlen[1] = 0
170 len = sum(extendlen) + 1
171 shrink = 1 / len
172 offset = extendlen[0] / len
173 # we need to reset the aspect ratio of the axes to account
174 # of the extends...
175 if hasattr(ax, '_colorbar_info'):
176 aspect = ax._colorbar_info['aspect']
177 else:
178 aspect = False
179 # now shrink and/or offset to take into account the
180 # extend tri/rectangles.
181 if self._cbar.orientation == 'vertical':
182 if aspect:
183 self._cbar.ax.set_box_aspect(aspect*shrink)
184 pos = pos.shrunk(1, shrink).translated(0, offset * pos.height)
185 else:
186 if aspect:
187 self._cbar.ax.set_box_aspect(1/(aspect * shrink))
188 pos = pos.shrunk(shrink, 1).translated(offset * pos.width, 0)
189 return pos
190
191 def get_subplotspec(self):
192 # make tight_layout happy..

Callers

nothing calls this directly

Calls 7

_proportional_yMethod · 0.80
_extend_lowerMethod · 0.80
_extend_upperMethod · 0.80
translatedMethod · 0.80
shrunkMethod · 0.80
get_positionMethod · 0.45
set_box_aspectMethod · 0.45

Tested by

no test coverage detected