Automatically set spine bounds to the view interval.
(self)
| 250 | return low, high |
| 251 | |
| 252 | def _adjust_location(self): |
| 253 | """Automatically set spine bounds to the view interval.""" |
| 254 | |
| 255 | if self.spine_type == 'circle': |
| 256 | return |
| 257 | |
| 258 | low, high = self._get_bounds_or_viewLim() |
| 259 | |
| 260 | if self._patch_type == 'arc': |
| 261 | if self.spine_type in ('bottom', 'top'): |
| 262 | try: |
| 263 | direction = self.axes.get_theta_direction() |
| 264 | except AttributeError: |
| 265 | direction = 1 |
| 266 | try: |
| 267 | offset = self.axes.get_theta_offset() |
| 268 | except AttributeError: |
| 269 | offset = 0 |
| 270 | low = low * direction + offset |
| 271 | high = high * direction + offset |
| 272 | if low > high: |
| 273 | low, high = high, low |
| 274 | |
| 275 | self._path = mpath.Path.arc(np.rad2deg(low), np.rad2deg(high)) |
| 276 | |
| 277 | if self.spine_type == 'bottom': |
| 278 | if self.axis is None: |
| 279 | tr = mtransforms.IdentityTransform() |
| 280 | else: |
| 281 | tr = self.axis.get_transform() |
| 282 | rmin, rmax = tr.transform(self.axes.viewLim.intervaly) |
| 283 | try: |
| 284 | rorigin = self.axes.get_rorigin() |
| 285 | except AttributeError: |
| 286 | rorigin = rmin |
| 287 | else: |
| 288 | rorigin = tr.transform(rorigin) |
| 289 | scaled_diameter = (rmin - rorigin) / (rmax - rorigin) |
| 290 | self._height = scaled_diameter |
| 291 | self._width = scaled_diameter |
| 292 | |
| 293 | else: |
| 294 | raise ValueError('unable to set bounds for spine "%s"' % |
| 295 | self.spine_type) |
| 296 | else: |
| 297 | v1 = self._path.vertices |
| 298 | assert v1.shape == (2, 2), 'unexpected vertices shape' |
| 299 | if self.spine_type in ['left', 'right']: |
| 300 | v1[0, 1] = low |
| 301 | v1[1, 1] = high |
| 302 | elif self.spine_type in ['bottom', 'top']: |
| 303 | v1[0, 0] = low |
| 304 | v1[1, 0] = high |
| 305 | else: |
| 306 | raise ValueError('unable to set bounds for spine "%s"' % |
| 307 | self.spine_type) |
| 308 | |
| 309 | @allow_rasterization |
no test coverage detected