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

Method _draw_offset_text

lib/mpl_toolkits/mplot3d/axis3d.py:485–554  ·  view source on GitHub ↗
(self, renderer, edgep1, edgep2, labeldeltas, centers,
                          highs, pep, dx, dy)

Source from the content-addressed store, hash-verified

483 tick.draw(renderer)
484
485 def _draw_offset_text(self, renderer, edgep1, edgep2, labeldeltas, centers,
486 highs, pep, dx, dy):
487 # Get general axis information:
488 info = self._axinfo
489 index = info["i"]
490 juggled = info["juggled"]
491 tickdir = info["tickdir"]
492
493 # Which of the two edge points do we want to
494 # use for locating the offset text?
495 if juggled[2] == 2:
496 outeredgep = edgep1
497 outerindex = 0
498 else:
499 outeredgep = edgep2
500 outerindex = 1
501
502 pos = _move_from_center(outeredgep, centers, labeldeltas,
503 self._axmask())
504 olx, oly, olz = proj3d.proj_transform(*pos, self.axes.M)
505 self.offsetText.set_text(self.major.formatter.get_offset())
506 self.offsetText.set_position((olx, oly))
507 angle = art3d._norm_text_angle(np.rad2deg(np.arctan2(dy, dx)))
508 self.offsetText.set_rotation(angle)
509 # Must set rotation mode to "anchor" so that
510 # the alignment point is used as the "fulcrum" for rotation.
511 self.offsetText.set_rotation_mode('anchor')
512
513 # ----------------------------------------------------------------------
514 # Note: the following statement for determining the proper alignment of
515 # the offset text. This was determined entirely by trial-and-error
516 # and should not be in any way considered as "the way". There are
517 # still some edge cases where alignment is not quite right, but this
518 # seems to be more of a geometry issue (in other words, I might be
519 # using the wrong reference points).
520 #
521 # (TT, FF, TF, FT) are the shorthand for the tuple of
522 # (centpt[tickdir] <= pep[tickdir, outerindex],
523 # centpt[index] <= pep[index, outerindex])
524 #
525 # Three-letters (e.g., TFT, FTT) are short-hand for the array of bools
526 # from the variable 'highs'.
527 # ---------------------------------------------------------------------
528 centpt = proj3d.proj_transform(*centers, self.axes.M)
529 if centpt[tickdir] > pep[tickdir, outerindex]:
530 # if FT and if highs has an even number of Trues
531 if (centpt[index] <= pep[index, outerindex]
532 and np.count_nonzero(highs) % 2 == 0):
533 # Usually, this means align right, except for the FTT case,
534 # in which offset for axis 1 and 2 are aligned left.
535 if highs.tolist() == [False, True, True] and index in (1, 2):
536 align = 'left'
537 else:
538 align = 'right'
539 else:
540 # The FF case
541 align = 'left'
542 else:

Callers 1

drawMethod · 0.95

Calls 8

_axmaskMethod · 0.95
_move_from_centerFunction · 0.85
set_rotationMethod · 0.80
set_rotation_modeMethod · 0.80
set_textMethod · 0.45
get_offsetMethod · 0.45
set_positionMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected