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

Skip to content

Commit 1afb165

Browse files
Cleanup and linting
1 parent d9afaf6 commit 1afb165

2 files changed

Lines changed: 12 additions & 33 deletions

File tree

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,8 @@ def _set_lim3d(self, axis, lower=None, upper=None, *, emit=True,
850850
lower_t, upper_t = transform.transform([lower, upper])
851851
delta = (upper_t - lower_t) * view_margin
852852
if np.isfinite(delta):
853-
lower, upper = inverse_trans.transform([lower_t - delta, upper_t + delta])
853+
new_range = [lower_t - delta, upper_t + delta]
854+
lower, upper = inverse_trans.transform(new_range)
854855
else:
855856
delta = (upper - lower) * view_margin
856857
lower -= delta

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,6 @@ def _move_from_center(coord, centers, deltas, axmask=(True, True, True)):
2222
return coord + axmask * np.copysign(1, coord - centers) * deltas
2323

2424

25-
def _apply_scale_to_coord(coord, axes):
26-
"""
27-
Apply scale transforms to a 3D coordinate.
28-
29-
Parameters
30-
----------
31-
coord : array-like of length 3
32-
The (x, y, z) coordinate in data space.
33-
axes : Axes3D
34-
The axes providing the scale transforms.
35-
36-
Returns
37-
-------
38-
array of length 3
39-
The coordinate in scaled space.
40-
"""
41-
coord = np.asarray(coord)
42-
x_trans = axes.xaxis.get_transform()
43-
y_trans = axes.yaxis.get_transform()
44-
z_trans = axes.zaxis.get_transform()
45-
return np.array([
46-
x_trans.transform([coord[0]])[0],
47-
y_trans.transform([coord[1]])[0],
48-
z_trans.transform([coord[2]])[0],
49-
])
50-
5125

5226
def _tick_update_position(tick, tickxs, tickys, labelpos):
5327
"""Update tick line and label position and style."""
@@ -318,8 +292,12 @@ def _get_coord_info(self):
318292
])
319293

320294
# Project the bounds along the current position of the cube:
321-
# Note: _transformed_cube expects data-space bounds and transforms them internally
322-
bounds = data_mins[0], data_maxs[0], data_mins[1], data_maxs[1], data_mins[2], data_maxs[2]
295+
# Note: _transformed_cube expects data-space bounds and transforms them
296+
# internally
297+
bounds = (data_mins[0], data_maxs[0],
298+
data_mins[1], data_maxs[1],
299+
data_mins[2], data_maxs[2]
300+
)
323301
bounds_proj = self.axes._transformed_cube(bounds)
324302

325303
# Determine which one of the parallel planes are higher up:
@@ -489,7 +467,8 @@ def _draw_ticks(self, renderer, edgep1, centers, deltas, highs,
489467
centers, deltas = self._calc_centers_deltas(maxs, mins)
490468

491469
# Get the scale transform for this axis to transform tick locations
492-
axis_trans = [self.axes.xaxis, self.axes.yaxis, self.axes.zaxis][index].get_transform()
470+
axis = [self.axes.xaxis, self.axes.yaxis, self.axes.zaxis][index]
471+
axis_trans = axis.get_transform()
493472

494473
# Draw ticks:
495474
tickdir = self._get_tickdir(pos)
@@ -574,9 +553,8 @@ def _draw_offset_text(self, renderer, edgep1, edgep2, labeldeltas, centers,
574553
# Three-letters (e.g., TFT, FTT) are short-hand for the array of bools
575554
# from the variable 'highs'.
576555
# ---------------------------------------------------------------------
577-
# Apply scale transforms before projection
578-
centers_scaled = _apply_scale_to_coord(centers, self.axes)
579-
centpt = proj3d.proj_transform(*centers_scaled, self.axes.M)
556+
# centers is already in scaled space (from _get_coord_info)
557+
centpt = proj3d.proj_transform(*centers, self.axes.M)
580558
if centpt[tickdir] > pep[tickdir, outerindex]:
581559
# if FT and if highs has an even number of Trues
582560
if (centpt[index] <= pep[index, outerindex]

0 commit comments

Comments
 (0)