Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e5d09e

Browse files
committed
Deprecate helper functions in axis3d
1 parent 972e95c commit 8e5d09e

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Helper functions in ``mplot3d.axis3d``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The two helper functions ``move_from_center`` and ``tick_update_position`` are
5+
considered internal and deprecated. If these are required, please vendor the
6+
code from the corresponding private methods ``_move_from_center`` and
7+
``_tick_update_position``.

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@
1212
from . import art3d, proj3d
1313

1414

15+
@_api.deprecated("3.6", alternative="Vendor the code of _move_from_center")
1516
def move_from_center(coord, centers, deltas, axmask=(True, True, True)):
17+
"""
18+
For each coordinate where *axmask* is True, move *coord* away from
19+
*centers* by *deltas*.
20+
"""
21+
return _move_from_center(coord, centers, deltas, axmask=axmask)
22+
23+
24+
def _move_from_center(coord, centers, deltas, axmask=(True, True, True)):
1625
"""
1726
For each coordinate where *axmask* is True, move *coord* away from
1827
*centers* by *deltas*.
@@ -21,8 +30,14 @@ def move_from_center(coord, centers, deltas, axmask=(True, True, True)):
2130
return coord + axmask * np.copysign(1, coord - centers) * deltas
2231

2332

33+
@_api.deprecated("3.6", alternative="Vendor the code of _tick_update_position")
2434
def tick_update_position(tick, tickxs, tickys, labelpos):
2535
"""Update tick line and label position and style."""
36+
_tick_update_position(tick, tickxs, tickys, labelpos)
37+
38+
39+
def _tick_update_position(tick, tickxs, tickys, labelpos):
40+
"""Update tick line and label position and style."""
2641

2742
tick.label1.set_position(labelpos)
2843
tick.label2.set_position(labelpos)
@@ -370,7 +385,7 @@ def draw(self, renderer):
370385
(self.labelpad + default_offset) * deltas_per_point * deltas)
371386
axmask = [True, True, True]
372387
axmask[index] = False
373-
lxyz = move_from_center(lxyz, centers, labeldeltas, axmask)
388+
lxyz = _move_from_center(lxyz, centers, labeldeltas, axmask)
374389
tlx, tly, tlz = proj3d.proj_transform(*lxyz, self.axes.M)
375390
self.label.set_position((tlx, tly))
376391
if self.get_rotate_label(self.label.get_text()):
@@ -391,7 +406,7 @@ def draw(self, renderer):
391406
outeredgep = edgep2
392407
outerindex = 1
393408

394-
pos = move_from_center(outeredgep, centers, labeldeltas, axmask)
409+
pos = _move_from_center(outeredgep, centers, labeldeltas, axmask)
395410
olx, oly, olz = proj3d.proj_transform(*pos, self.axes.M)
396411
self.offsetText.set_text(self.major.formatter.get_offset())
397412
self.offsetText.set_position((olx, oly))
@@ -491,10 +506,10 @@ def draw(self, renderer):
491506
labeldeltas = (tick.get_pad() + default_label_offset) * points
492507

493508
pos[tickdir] = edgep1_tickdir
494-
pos = move_from_center(pos, centers, labeldeltas, axmask)
509+
pos = _move_from_center(pos, centers, labeldeltas, axmask)
495510
lx, ly, lz = proj3d.proj_transform(*pos, self.axes.M)
496511

497-
tick_update_position(tick, (x1, x2), (y1, y2), (lx, ly))
512+
_tick_update_position(tick, (x1, x2), (y1, y2), (lx, ly))
498513
tick.tick1line.set_linewidth(tick_lw[tick._major])
499514
tick.draw(renderer)
500515

0 commit comments

Comments
 (0)