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

Skip to content

Commit bc61c81

Browse files
committed
More readability improvements on axis3d.
At least the comment helps me, and whole thing is shorter :)
1 parent 9856ec2 commit bc61c81

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ def draw(self, renderer):
283283
outeredgep = edgep2
284284
outerindex = 1
285285

286-
pos = outeredgep.copy()
287-
pos = move_from_center(pos, centers, labeldeltas, axmask)
286+
pos = move_from_center(outeredgep, centers, labeldeltas, axmask)
288287
olx, oly, olz = proj3d.proj_transform(*pos, renderer.M)
289288
self.offsetText.set_text(self.major.formatter.get_offset())
290289
self.offsetText.set_position((olx, oly))
@@ -339,19 +338,14 @@ def draw(self, renderer):
339338
self.offsetText.set_ha(align)
340339
self.offsetText.draw(renderer)
341340

342-
# Draw grid lines
343341
if self.axes._draw_grid and len(ticks):
344-
# Grid points at end of one plane
345-
xyz1 = xyz0.copy()
346-
newindex = (index + 1) % 3
347-
xyz1[:, newindex] = maxmin[newindex]
348-
349-
# Grid points at end of the other plane
350-
xyz2 = xyz0.copy()
351-
newindex = (index + 2) % 3
352-
xyz2[:, newindex] = maxmin[newindex]
353-
354-
lines = np.stack([xyz1, xyz0, xyz2], axis=1)
342+
# Grid lines go from the end of one plane to the plane intersection
343+
# (at xyz0) to the end of the other plane. The first point (0)
344+
# differs along dimension index-2 and the last (2) along dimension
345+
# index-1.
346+
lines = np.stack([xyz0, xyz0, xyz0], axis=1)
347+
lines[:, 0, index - 2] = maxmin[index - 2]
348+
lines[:, 2, index - 1] = maxmin[index - 1]
355349
self.gridlines.set_segments(lines)
356350
self.gridlines.set_color(info['grid']['color'])
357351
self.gridlines.set_linewidth(info['grid']['linewidth'])

0 commit comments

Comments
 (0)