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

Skip to content

Commit a0f16a8

Browse files
authored
Merge pull request #23675 from oscargus/axis3ddeprecations
Deprecate helper functions in axis3d
2 parents 3f0bc53 + b89ed57 commit a0f16a8

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
@@ -13,7 +13,16 @@
1313
from . import art3d, proj3d
1414

1515

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

2433

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

2843
tick.label1.set_position(labelpos)
2944
tick.label2.set_position(labelpos)
@@ -371,7 +386,7 @@ def draw(self, renderer):
371386
(self.labelpad + default_offset) * deltas_per_point * deltas)
372387
axmask = [True, True, True]
373388
axmask[index] = False
374-
lxyz = move_from_center(lxyz, centers, labeldeltas, axmask)
389+
lxyz = _move_from_center(lxyz, centers, labeldeltas, axmask)
375390
tlx, tly, tlz = proj3d.proj_transform(*lxyz, self.axes.M)
376391
self.label.set_position((tlx, tly))
377392
if self.get_rotate_label(self.label.get_text()):
@@ -392,7 +407,7 @@ def draw(self, renderer):
392407
outeredgep = edgep2
393408
outerindex = 1
394409

395-
pos = move_from_center(outeredgep, centers, labeldeltas, axmask)
410+
pos = _move_from_center(outeredgep, centers, labeldeltas, axmask)
396411
olx, oly, olz = proj3d.proj_transform(*pos, self.axes.M)
397412
self.offsetText.set_text(self.major.formatter.get_offset())
398413
self.offsetText.set_position((olx, oly))
@@ -492,10 +507,10 @@ def draw(self, renderer):
492507
labeldeltas = (tick.get_pad() + default_label_offset) * points
493508

494509
pos[tickdir] = edgep1_tickdir
495-
pos = move_from_center(pos, centers, labeldeltas, axmask)
510+
pos = _move_from_center(pos, centers, labeldeltas, axmask)
496511
lx, ly, lz = proj3d.proj_transform(*pos, self.axes.M)
497512

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

0 commit comments

Comments
 (0)