Skip to content

Commit 38fd0c2

Browse files
authored
Merge pull request #15027 from anntzer/axis3d
More readability improvements on axis3d.
2 parents e34f7ee + 739d183 commit 38fd0c2

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/mpl_toolkits/mplot3d/axis3d.py

+8-14
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 through the plane
343+
# intersection (at xyz0) to the end of the other plane. The first
344+
# point (0) differs along dimension index-2 and the last (2) along
345+
# dimension 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)